王小二切餅 (sdut oj)


王小二切餅

Time Limit: 1000MS Memory Limit: 65536KB


Problem Description

王小二自誇刀工不錯,有人放一張大的煎餅在砧板上,問他:“餅不許離開砧板,切n(1<=n<=100)刀最多能分成多少塊?”


Input

輸入切的刀數n。


Output

輸出爲切n刀最多切的餅的塊數。


Example Input

100


Example Output

5051

Hint

 

Author








參考代碼




#include<stdio.h>
int f(int n)
{
    if( n > 1 )
        n += f(n - 1);
    return n;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
        printf("%d\n",f(n)+1);
    return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章