CodeForces 592B The Monster and the Squirrel

规律题,多画几个就能找到规律了。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

long long a[60000];
long long C;

int main()
{
    a[3]=1; C=3;
    for(int i=4;i<=54321;i++)
    {
        a[i]=a[i-1]+C;
        C=C+2;
    }

    int n;
    while(~scanf("%d",&n))
    printf("%lld\n",a[n]);
    return 0;
}

 

posted @ 2016-05-07 20:56  Fighting_Heart  阅读(113)  评论(0编辑  收藏  举报