[恢]hdu 2139
2011-12-16 07:00:16
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2139
题意:算平方和的奇数项目。
mark:1wa,没用long long。公式是(4*p*p*p+12*p*p+11*p+3)/3。其中2p+1 == n。
代码:
# include <stdio.h>
int main ()
{
long long n, p ;
while (~scanf ("%I64d", &n))
{
p = (n-1) / 2 ;
printf ("%I64d\n", (4*p*p*p+12*p*p+11*p+3)/3) ;
}
return 0 ;
}