http://acm.hdu.edu.cn/showproblem.php?pid=1290
这是一道让我很没脾气的数学题,一个人告诉我二维的是f(x) = a*x^2 + b*x + c,
三维的是f(x) = a*x^3 + b*x^2 + c*x + d,用待定系数法求出公式再计算就OK 了...
这道题的公式推出来是f(x) = (x^3 + 5x + 6) /6
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
cout << ( n*n*n + 5*n + 6) / 6 <<endl;
}
return 0;
}
看来以后还得多学习些小窍门,不然傻想到啥时候...才能得出结果