hdu 2139

 

#include<stdio.h>
int main()
{
__int64 n;
while(scanf("%I64d",&n)!=EOF)
{
n=(n+2)*(n+1)*n/6;
printf("%I64d\n",n);
}
return 0;
}

Calculate the formula

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4178    Accepted Submission(s): 1229


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

 

發佈了171 篇原創文章 · 獲贊 9 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章