SDUT 王小二切饼

Problem Description

王小二自夸刀工不错,有人放一张大的煎饼在砧板上,问他:“饼不许离开砧板,切n(1<=n<=100)刀最多能分成多少块?”
Input

输入切的刀数n。
Output

输出为切n刀最多切的饼的块数。
Example Input

100
Example Output

5051
Hint

Author

代码

#include <stdio.h>
int main()
{
    int n,i,f[101];
    scanf("%d",&n);
    f[1]=2;
    for(i=2;i<=n;i++)
    {
        f[i] = f[i-1] + i;
    }
    printf("%d",f[n]);
    return 0;
}

递推算法

原文地址:https://www.cnblogs.com/lushans/p/6683773.html