HDU2050 折线分割平面 (线段数学规律)

 折线分割平面

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 20030    Accepted Submission(s): 13742


Problem Description
我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。
HDU折线分割平面 - 凌晨一点 - 虚灵
 

Input
输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。

 

Output
对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。

 

Sample Input
2 1 2
 

Sample Output
2 7
 

Author
lcy
 

Source
 

Recommend
lcy   |   We have carefully selected several similar problems for you:  2501 1480 1466 1438 2563 
#include <iostream>
#include <cstdio>
using namespace std;
 
int main(void)
{
    __int64 a[10005];
    __int64 s[10005];
    int n,i,t,c;
    s[1]=2;
    s[2]=7;
    for(i=1;i<=10000;i++)
    {
        a[i]=2*i;
    }
    for(t=3;t<=10000;t++)
    {
        s[t]=s[t-1]+1+2*a[t-1];
    }
    scanf("%d",&c);
    while(c--)
    {
        scanf("%d",&n);
        printf("%I64d\n",s[n]);
    }
 
}
 
 

 

posted @ 2015-08-22 17:24  Lincy*_*  阅读(207)  评论(0编辑  收藏  举报