Polyline division plane HDU - 2050 (Recursive)

We've seen a lot of straight division title plane, today's change the subject slightly, we ask for is the n fold line dividing the maximum number of planes. For example, a fold line may be divided into two planar, two folds up into the planar portion 7, as shown below.

Input
first line of input data C is an integer, indicates the number of test cases, then the C line data, each line contains an integer n (0 <n <= 10000 ), represents the number of fold lines.

Output
For each test instance, the maximum division number output plane, the output of each row for instance.

Sample Input
2
1
2
Sample Output
2
7

Ideas:
adding a straight line, the straight line with each other there is a point of intersection, the more one. Many blocks as the number of intersections is +1.
Then after adding up a plurality polyline line 4 * (n-1) + 1 regions,
it is 5 + 1 + 1 +. . . + 4 * (n - 1) + 1.
Add up to 2 * n * n - n + 1.

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int T;scanf("%d",&T);
    while(T--)
    {
        int n;scanf("%d",&n);
        printf("%d\n",2 * n * n - n + 1);
    }
    return 0;
}
Published 676 original articles · won praise 18 · views 30000 +

Guess you like

Origin blog.csdn.net/tomjobs/article/details/104230232