hdu1290

这类问题一般都有固定的公式,告诉大家一个技巧:二维的一般是f(x)=a*x^2+b*x+c,三维的一般是f(x)=a*x^3+b*x^2+c*x+d. 用带定系数法求出各个系数就行了。

http://acm.hdu.edu.cn/showproblem.php?pid=1290

View Code
#include"iostream"
using namespace std;
int main()
{
int n;
while(cin>>n)
{
cout
<<(n*n*n+5*n+6)/6<<endl;
}
return 0;
}
原文地址:https://www.cnblogs.com/FCWORLD/p/2003956.html