UVA10079 Pizza Cutting【水题】
2017-03-28 16:53
393 查看
When someone calls Ivan lazy, he claims that it is his intelligence that helps him to be so. If hisintelligence allows him to do something at less physical effort, why should he exert more?
He alsoclaims 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 itamong his friends. (Size of the pieces may not be the same. In fact, hispiece will be larger than the others.) He thought
a bit, and came to theconclusion that he can cut it into seven pieces by only three straight cutsthrough the pizza with a pizza knife. Accordingly, he cut the pizza in thefollowing way (guess which one is Ivan’s piece):
One of his friends, who never believed in Ivan’s smartness, was startledat 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 criticizehim for stealing his idea) job with his computer. He wrote a program thattook the number of straight cuts one makes through the pizza, and output a number representing themaximum 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 fordoing the same job he did.
Input
The input file will contain a single integer N (0 ≤ N ≤ 210000000) in each line representing the numberof 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 shouldcontain only one output integer without any leading or trailing space.
Sample Input
5
10
-100
Sample Output
16
56
问题链接:UVA10079 Pizza Cutting。
问题描述:参见上述链接。
问题分析:参考《具体数学》一书。也可以参考:直线分平面公式_百度百科。
程序说明:(略)
AC的C++语言程序如下:
He alsoclaims 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 itamong his friends. (Size of the pieces may not be the same. In fact, hispiece will be larger than the others.) He thought
a bit, and came to theconclusion that he can cut it into seven pieces by only three straight cutsthrough the pizza with a pizza knife. Accordingly, he cut the pizza in thefollowing way (guess which one is Ivan’s piece):
One of his friends, who never believed in Ivan’s smartness, was startledat 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 criticizehim for stealing his idea) job with his computer. He wrote a program thattook the number of straight cuts one makes through the pizza, and output a number representing themaximum 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 fordoing the same job he did.
Input
The input file will contain a single integer N (0 ≤ N ≤ 210000000) in each line representing the numberof 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 shouldcontain only one output integer without any leading or trailing space.
Sample Input
5
10
-100
Sample Output
16
56
问题链接:UVA10079 Pizza Cutting。
问题描述:参见上述链接。
问题分析:参考《具体数学》一书。也可以参考:直线分平面公式_百度百科。
程序说明:(略)
AC的C++语言程序如下:
/* UVA10079 Pizza Cutting */ #include <iostream> using namespace std; int main() { long long n; while(cin >> n && n >= 0) { cout << 1 + n * (n + 1) / 2 << endl; } return 0; }
相关文章推荐
- Uva 10079 - Pizza Cutting 解题报告(递推)
- UVA10079 - Pizza Cutting(数论)
- UVA - 10079 Pizza Cutting (直线划分平面问题,公式解决)
- uva 10079 - Pizza Cutting
- UVA 10079 Pizza Cutting(数论)
- UVa 10079 - Pizza Cutting
- UVa 10079 Pizza Cutting (water ver.)
- uva 10079 - Pizza Cutting
- uva 1203 - Argus (数据结构:优先队列+水题)
- UVa 11100 The Trip, 2007 (水题)
- UVa 10192 - Vacation(LCS水题)
- uva 565 - Pizza Anyone?
- uva 565 - Pizza Anyone?
- uva 11489 - Integer Game(水题)
- UVA 10970 Big Chocolate(水题)
- UVA 575 Skew Binary 数学的水题
- UVa 10079 - Pizza Cutting
- UVA - 539 The Settlers of Catan (回溯水题)
- UVA100 POJ1207 HDU1032 The 3n + 1 problem【水题】