# UVA Problem 10079 – Pizza Cutting Solution

UVA Problem 10079 – Pizza Cutting Solution:

Solving Technique:

This is a very simple mathematics problem. It can be solved with Gauss‘es arithmetic series formula. Which is the sum 1 to nth number. The formula is,

#### n * ( n + 1 )/2

The problem just requires us find the number of maximum possible pieces for given the number of cuts. At first the pattern may not be visible. Use pencil and paper draw and verify outputs.

We need add 1 since doing 1 cut in pizza makes two pieces. So the arithmetic series formula is 1 less. Again if we make two cuts using arithmetic progression formula it is 1 less again. It happens for all inputs. So we can add 1 with result of this formula and that is the answer.

This problem can also be solved using simple loop and sum from 1 to n.

A corner case may be that the number may not fit int range.

Important:  Be sure to add or print a new line after each output unless otherwise specified. The outputs should match exactly because sometimes even a space character causes the answer to be marked as wrong answer.

Input:

```5
10
-100```

Output:

```16
56```

Code:

```/**
* @author  Quickgrid ( Asif Ahmed )
* Problem: UVA 10079 Pizza Cutting
*/

#include<stdio.h>

int main(){
long long n;
while(scanf("%lld", &n)){
if(n < 0)
return 0;

/**
* Arithmetic series 1 to n with extra 1
*/
printf("%lld\n", 1 + n * (n + 1) / 2);
}
return 0;
}
```