Uva 10079 - Pizza Cutting 解题报告(递推)
来源:互联网 发布:ios软件开发是什么 编辑:程序博客网 时间:2024/05/17 23:46
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:
510
-100
Sample Output:
1656
解题报告: 也算是简单题了。初始状态为一块。第一刀切下去,与0条直线相交,多出来1块。第二刀切下去,最多与1条直线相交,多出来2块。然后依次是3块,4块,5块。总结出公式1+n*(n+1)/2。注意用long long 。懒得贴代码了。
- Uva 10079 - Pizza Cutting 解题报告(递推)
- UVA 10079 Pizza Cutting
- UVa 10079 - Pizza Cutting
- UVA 10079 Pizza Cutting
- uva 10079 - Pizza Cutting
- UVa 10079 - Pizza Cutting
- uva 10079 - 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 - 10003Cutting Sticks(递推)
- Uva 11375 Matches 解题报告(递推+高精度)
- Uva 11137 Ingenuous Cubrency 解题报告(递推)
- Uva 10253 - Series-Parallel Networks 解题报告(递推)
- Uva 1393 - Highways 解题报告(递推)
- Uva 11645 - Bits 解题报告(递推+大数)
- java.lang.ExceptionInInitializerError异常解决小结
- UBOOT介绍
- Activity
- Hive语言手册之二:变量替换
- 【经典排序算法】桶排序
- Uva 10079 - Pizza Cutting 解题报告(递推)
- linux中/usr 的由来及/usr目录结构
- C#语言SqlClient接口SQL Server数据库类
- Loki的SingletonHolder解析
- Ant 在Myeclipse8+ 编译java类卡死的解决方案
- log4j总结
- 将hibernate的SessionFactory交给spring管理——东方标准(专注IT、服务中国)续……
- 数据库SQL语句书写注意事项
- 图像特征之LBP 局部二值模式