zoukankan      html  css  js  c++  java
  • [解题报告]10079 Pizza Cutting

    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:

    5
    10
    -100

    Sample Output:

    16
    56
    __________________________________________________________________________________________
    Rezaul Alam Chowdhury

    纯小学奥数题。。。。

    总结出公式就是水题。。。

    #include<stdio.h>
    int main()
    {
      long long N;
      while(scanf("%lld",&N)!=EOF&&N>=0)
        printf("%lld\n",(N+1)*N/2+1);
      return 0;
    }
  • 相关阅读:
    struct2 学习总结
    c++ 容器(list学习总结)
    java 网络编程(五)----TCP进阶篇上传文本文件
    java 网络编程(四)----UDP进阶篇聊天小程序
    java 网络编程(三)---TCP的基础级示例
    java 网络编程(二)----UDP基础级的示例
    java 网络编程(一)---基础知识和概念了解
    GitHub和git和repo的使用
    android studio不能预览
    关于android studio2.3和android studio3.0
  • 原文地址:https://www.cnblogs.com/TheLaughingMan/p/2932102.html
Copyright © 2011-2022 走看看