When n≥2, an=Sn-Sn- 1=n2+3n2-(n? 1)2+3(n? 1)2=n+ 1,
When n= 1, a 1= 1+ 1=2 satisfies the question.
So the general formula of the sequence {an} is an = n+ 1 (n ∈ n *).
(2) When n is even, TN = (b1+B3+…+BN-1)+(B2+B4+…+BN) = (a1+A3+…+An-1)+
=a 1+an? 12? n2+4( 1? 2n) 1? 4=n2+2n4+43(2n- 1)。
When n is odd, n+ 1 is even.
Then TN+1= (n+1) 2+2 (n+1) 4+43 (2n+1-1).
= N2+4n+34+43(2n+ 1- 1),
And TN+1= TN+bn+1= TN+2n+1,
∴Tn=n2+4n+34+ 13? 2n+ 1-43。
(3) According to the program block diagram, p = N24+24n.
Let the general formula of the sequence {dn} be dn=Tn-P(n∈N*),
When n is odd, dn= 13? 2n+ 1-23n-7 12, let dn+2-dn = 2n+ 1-46 > 0, then n≥5,
∴ Starting from the fifth item, odd items in the sequence {dn} increase, while d 1, d3, …, d1/are all less than 2 009, and d 13 > 2 009.
∴ DN ≠ 2 009。 When n is an even number, dn=23? 2n+ 1-472n-43, let dn+2-dn = 2n+2-47 > 0, then n≥4,
The ∴ even items in series {dn} increase from the fourth item, while d2, d4, …, d 10 are all less than 2 009, and D 12 > 2 009.
∴ dn≠2 009 (n ∈ n *)。 So DN ≠ 2 009, that is, Tn-P≠2 009(n∈N*),
That is, the program is an infinite loop, so the teacher's judgment is correct.