您的位置:首页 > 编程语言 > C语言/C++

SDUT_王小二切饼_递推

2018-03-12 10:27 253 查看

王小二切饼

Time Limit: 1000 ms Memory Limit: 65536 KiB[align=center]Submit Statistic[/align]

Problem Description

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

Input

输入切的刀数n。

Output

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

Sample Input

100

Sample Output

5051

Hint

#include<stdlib.h>
#include<stdio.h>
int main(){
int n;
while(scanf("%d",&n)!=EOF&&n!=0){
printf("%d\n",n*(n+1)/2+1);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C语言 递推