本文主要是介绍王小二切饼 (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;
}
这篇关于王小二切饼 (sdut oj)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!