Original question:
Description
Problem E
Pizza Cutting
Input:Standard Input
Output:Standard output
When someone CILS 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 showould 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 in 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 shoshould contain only one output integer without any leading or trailing space.
Sample input:
5
10
-100
Sample output:
16
56
Analysis:
It is the minimum number of knives and the most Cut pie ~~~~ Remember the formula-P (minimum number of knives, number of slices with the most cut) = n × (n + 1)/2 + 1
Original code:
#include<stdio.h>int main(){ long long n; while(scanf("%lld",&n) && n>=0) { printf("%lld\n",n*(n+1)/2+1); } return 0;}