王小二切饼
Time Limit: 1000 ms Memory Limit: 65536 KiB
Submit Statistic
Problem Description
王小二自夸刀工不错,有人放一张大的煎饼在砧板上,问他:“饼不许离开砧板,切n(1<=n<=100)刀最多能分成多少块?”
Input
输入切的刀数n。
Output
输出为切n刀最多切的饼的块数。
Sample Input
100
Sample Output
5051
#include <stdio.h>
int main()
{
int n, i;
long long a[1000005];
while(~scanf("%d",&n))
{
a[1] = 2;
a[2] = 4;
for(i = 3; i <= n; i++)
a[i] = a[i - 1] + i;
printf("%lld\n",a[n]);
}
return 0;
}