Problem description we have seen a lot of 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. A line can divide a plane into seven parts at most, as shown below.
The first line of 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, the maximum number of partitions in the output plane. The output of each instance occupies one row.
Sample Input
212
Sample output
27
F (n) = f (n-1) + 2 * (n-1) + (2 * (n-1) + 1)
2 * (n-1) indicates that the newly added line splits an existing 2 * (n-1) edge into 2 * (n-1) planes)
(2 * (n-1) + 1) indicates the plane Obtained from the split of the newly added line. Because the first n-1 line has 2 * (n-1) lines. (3, 4, 5)
F (n-1) is 6, 7
#include <stdio.h>int arr[10001] = {0,2,7};int n,c;int main(){for(int i=3; i<=10000; i++){arr[i] = arr[i-1] + 4*(i-1) + 1;}scanf("%d",&c);while(c--){scanf("%d",&n);printf("%d\n",arr[n]);}return 0;}