找规律,不能直接算,否则超时
n=(n+2)*(n+1)*n/6;
#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;
}
找规律,不能直接算,否则超时
n=(n+2)*(n+1)*n/6;
#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;
}
转载于:https://www.cnblogs.com/yyf573462811/archive/2012/10/15/6365183.html