您的位置:首页 > 编程语言 > C语言/C++

杭电2139

2015-07-25 10:20 405 查看


Calculate the formula

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 7770    Accepted Submission(s): 2393


Problem Description

You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.

 

Input

In each case, there is an odd positive integer n.

 

Output

Print the sum. Make sure the sum will not exceed 2^31-1

 

Sample Input

3

 

Sample Output

10

 

Author

wangye

 

Source

HDU 2007-11 Programming Contest_WarmUp

 
水题……打表
#include <iostream>
using namespace std;
__int64 x[10000];
int main()
{
int m,n,i;

x[1]=1;
for(i=3;i<=10000;i++)
{
x[i]=x[i-2]+i*i;
}
while (cin>>n)
{
printf("%I64d\n",x
);
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM c++ 杭电