点击获取原题链接
王小二切饼
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 <bits/stdc++.h>
using namespace std;
int a[
100+
10];
int main()
{
a[
1]=
2;
a[
2]=
4;
a[
3]=
7;
for(
int i=
3;i<=
100;i++)
{
a[i]=a[i-
1]+i;
}
int n;
while(
cin>>n)
{
cout<<a[n]<<endl;
}
}
转载请注明原文地址: https://ju.6miu.com/read-4324.html