王小二切饼

来源:互联网 发布:剑灵邀请一直网络忙 编辑:程序博客网 时间:2024/06/05 16:23

王小二切饼

Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic

Problem Description

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

Input

输入切的刀数n。

Output

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

Example Input

100

Example Output

5051
代码:切饼问题:#include <stdio.h> #include <stdlib.h>int main(){   int n,i;   scanf("%d",&n);       long long int h[102];       h[1] = 2;       for(i=2;i<=n;i++)        h[i] = h[i-1]+i;       printf("%lld\n",h[n]);    return 0;}老师的思路:把外围的圆也看成一条线,新切的线要与原来的每条线都相交,切几条线增加几块,于是得出公式。暑假里教妹妹数学时有这么一个题,n条线相交,焦点的个数最多有多少个,焦点越多,增加的块数即可得出规律。
原创粉丝点击