折线分割平面
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 49 Accepted Submission(s) : 39
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description 我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。
Input 输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0
Output 对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。
Sample Input
2
1
2
Sample Output
2
7
Author lcy
Source 递推求解专题练习(For Beginner) AC代码:
#include
#include
using namespace std; int main(){ int a[10010]={0,2},i; for(i=2;i<10010;++i){ a[i]=2*i*i-i+1; } int k,n; cin>>n; while(n--){ cin>>k; printf("%d\n",a[k]); } return 0; }
|