这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1290
这类问题一般都有固定的公式,告诉大家一个技巧:二维的一般是an^2+bn+c,
三维的一般是an^3+bn^2+cn+d.
用待定系数法求出各个系数就OK了,不用想破脑筋找规律。。。。。。 0rz…..此乃神人
(n * n * n + 5*n) / 6 + 1;
#include
using namespace std;
int main ()
{
int N;
while ( scanf ( "%d", &N; ) != EOF ) {
printf ( "%d\n", ( N * N * N + 5 * N ) / 6 + 1 );
}
return 0;
}