省赛AK练习赛之Pizza Cutting
2013-04-02 14:27
225 查看
原题:
Description
Problem E
Pizza Cutting
Input:standard input
Output: standard output
When someone calls Ivan lazy, he claims that it is his intelligence that helps him to be so. If his intelligence allows him to do something at less physical effort, why should he exert more? He also claims that he always uses his brain and tries to do some work at less effort; this is not his laziness, rather this is his intellectual smartness.
Once Ivan was asked to cut a pizza into seven pieces to distribute it among his friends. (Size of the pieces may not be the same. In fact, his piece will be larger than the others.) He thought a bit, and came to the conclusion that he can cut it into seven pieces by only three straight cuts through the pizza with a pizza knife. Accordingly, he cut the pizza in the following way (guess which one is Ivan's piece):
One of his friends, who never believed in Ivan’s smartness, was startled at this intelligence. He thought, if Ivan can do it, why can’t my computer? So he tried to do a similar (but not exactly as Ivan's, for Ivan will criticize him for stealing his idea) job with his computer. He wrote a program that took the number of straight cuts one makes through the pizza, and output a number representing the maximum number of pizza pieces it will produce.
Your job here is to write a similar program. It is ensured that Ivan’s friend won’t criticize you for doing the same job he did.
Input
The input file will contain a single integer N (0 <= N <= 210000000) in each line representing the number of straight line cuts one makes through the pizza. A negative number terminates the input.
Output
Output the maximum number of pizza pieces the given number of cuts can produce. Each line should contain only one output integer without any leading or trailing space.
Sample Input:
5
10
-100
Sample Output:
16
56
分析:
就是最少的刀数,切最多的饼~~~~记住公式——p(最少的刀数,切最多的饼的块数)=n×(n+1)/2+1
原码:
Description
Problem E
Pizza Cutting
Input:standard input
Output: standard output
When someone calls Ivan lazy, he claims that it is his intelligence that helps him to be so. If his intelligence allows him to do something at less physical effort, why should he exert more? He also claims that he always uses his brain and tries to do some work at less effort; this is not his laziness, rather this is his intellectual smartness.
Once Ivan was asked to cut a pizza into seven pieces to distribute it among his friends. (Size of the pieces may not be the same. In fact, his piece will be larger than the others.) He thought a bit, and came to the conclusion that he can cut it into seven pieces by only three straight cuts through the pizza with a pizza knife. Accordingly, he cut the pizza in the following way (guess which one is Ivan's piece):
One of his friends, who never believed in Ivan’s smartness, was startled at this intelligence. He thought, if Ivan can do it, why can’t my computer? So he tried to do a similar (but not exactly as Ivan's, for Ivan will criticize him for stealing his idea) job with his computer. He wrote a program that took the number of straight cuts one makes through the pizza, and output a number representing the maximum number of pizza pieces it will produce.
Your job here is to write a similar program. It is ensured that Ivan’s friend won’t criticize you for doing the same job he did.
Input
The input file will contain a single integer N (0 <= N <= 210000000) in each line representing the number of straight line cuts one makes through the pizza. A negative number terminates the input.
Output
Output the maximum number of pizza pieces the given number of cuts can produce. Each line should contain only one output integer without any leading or trailing space.
Sample Input:
5
10
-100
Sample Output:
16
56
分析:
就是最少的刀数,切最多的饼~~~~记住公式——p(最少的刀数,切最多的饼的块数)=n×(n+1)/2+1
原码:
#include<stdio.h> int main() { long long n; while(scanf("%lld",&n) && n>=0) { printf("%lld\n",n*(n+1)/2+1); } return 0; }
相关文章推荐
- uva 10079 - Pizza Cutting
- uva 10079 - Pizza Cutting
- UVA - 10079 Pizza Cutting (直线划分平面问题,公式解决)
- UVA10079 Pizza Cutting【水题】
- UVA 10079 Pizza Cutting(数论)
- UVA10079 - Pizza Cutting(数论)
- UVa 10079 - Pizza Cutting
- Uva 10079 - Pizza Cutting 解题报告(递推)
- UVa 10079 Pizza Cutting (water ver.)
- 不吃Papa Pizza--棒约翰
- GETZ PIZZA – Home Delivery Management
- XTU (湘潭大学) 2011 新生练习赛(第一场)/ 解题报告 4.4
- uva 11008 Antimatter Ray Clearcutting
- 【动态规划】 TopCoder SRM 555 CuttingBitString
- 2013.04.20校内组队练习赛被虐总结
- 130722练习赛CF
- HDU 1154 Cutting a Polygon(基础计算几何知识综合应用)
- NWERC 2012 练习赛题解
- 练习赛6.1.回文数
- 练习赛13.4.求后序遍历