hdu 2139 Calculate the formula (递推)

点击打开链接

找规律,不能直接算,否则超时

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;
}


posted on 2012-10-15 13:10  Slege  阅读(68)  评论(0编辑  收藏  举报

导航