We've seen a lot of straight-line split-plane problems, and this topic is slightly different today, and we're asking for the maximum number of n-polyline split planes. For example, a polyline can divide the plane into two parts, and a maximum of two polylines can be divided into 7 parts, as shown below.
Input
The first line of the input data is an integer c, representing the number of test instances, followed by the C row of data, each line containing an integer n (0<n<=10000), representing the number of polylines.
Output
For each test instance, output the maximum number of partitions for the plane, and the output for each instance takes up one row.
Sample Input
2
1
2
Sample Output
2
7
#include <iostream>
using namespace Std;
int main ()
{
int n,m,i,j;
Long Long x[10002];
cin>>m;
for (j=1;j<=m;j++)
{
cin>>n;
x[0]=0;x[1]=2;x[2]=7;
for (i=3;i<=n;i++)
{
x[i]=x[i-1]+4*i-3;
}
cout<<x[n]<<endl;
}
return 0;
}
Polyline split plane