Problem description We have seen many questions about straight line split planes. Today's questions are slightly changed. What we need is the maximum number of N line split planes. For example, a line can divide a plane into two parts, and a line can divide a plane into seven parts at most.
Input The first line of the input data is an integer c, indicating the number of test instances, followed by data in Row C. Each row contains an integer N (0 <n <= 10000 ), the number of broken lines.
Output For each test instance, specify the maximum number of partitions in the output plane. The output of each instance occupies one row.
Sample Input
212
Sample output
27
A typical recursive solution.
The law must be found from n = 1, 2, 3 through recursion.
We can see from the drawing that,Number of planes = number of vertices + intersection points + 1
By assuming that F (N-1) is known, another line splits the plane to maximize the number of planes, the line must pass through all other lines, so f (n) ratio F (N-1) 4 more (N-1) (two line intersection can generate 4 intersections) Another vertex also has one more. So the recursive formula can be obtained: F (N)-f (N-1) = 4 (N-1) + 1. Through the Recursive Method of High School series can be obtained:
F (n) = 2n ^ 2-N + 1;
# Include <iostream> </P> <p> using namespace STD; </P> <p> int main () <br/>{< br/> int N, c; <br/> CIN> C; <br/> for (INT I = 0; I <C; I ++) <br/>{< br/> CIN> N; <br/> cout <2 * n-n + 1 <Endl; <br/>}< br/> return 0; <br/>}</P> <p>