UVa 10079 Pizza Cutting (water ver.)

Source: Internet
Author: User
Tags time limit

10079-pizza Cutting

Time limit:8.333 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1020

When someone calls Ivan lazy, he claims the it IS's his intelligence that helps the to being so. If His intelligence allows him to do something at less physical effort, why should he exert? He also claims the He always uses his brain and tries to do some at work less; This is isn't his laziness, rather the this IS's his intellectual smartness.

Once Ivan is asked to cut a pizza into seven pieces to distribute it among his friends. (The Size of the pieces may is the same.) In fact, his piece would be larger than the others.) He thought a bit, and came to the conclusion so 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 does it, why can ' my computer? So he tried to do a similar (but is not exactly as Ivan's, for Ivan would criticize him for stealing him) job with his CO Mputer. He wrote the took the number of straight cuts one makes through the pizza, and output a number representing the Maximum number of pizza pieces it'll produce.

Your job is in to write a similar. It is ensured that Ivan's friend won ' t criticize for doing the same job he did.

Input

The input file would contain a single integer N (0 <= N <= 210000000) in each line representing the number of Straig HT 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 spaces.

Sample Input:

5

10

-100

Sample Output:

16

56

Complete code:

/*0.012s*/
  
#include <cstdio>
  
int main (void)
{
    long long n;
    while (scanf ("%lld", &n), n >= 0)
        printf ("%lld\n", ((n * n + N) >> 1) + 1);
    return 0;
}

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.