zoukankan      html  css  js  c++  java
  • UVA 10499 (13.08.06)

    Problem H
    The Land of Justice
    Input: standard input
    Output: standard output
    Time Limit: 4 seconds

    In the Land of Justice theselling price of everything is fixed all over the country. Nobody can buy a thingand sell it in double price. But, that created problems for the businessmen.They left their business and went to the production. So, after some dayseverybody was in production and nobody in business. And the people didn’t gettheir necessary things though the country was self-sufficient in every sector.

    The government became very muchanxious. But, they were intelligent enough to call the mathematicians.

    The mathematicians gave asolution.  They suggested setting thesurface area of an object as its selling-unit instead of its volume. Actuallythe clever mathematicians were very much interested to establish their ownbusiness.

    Now, the government asks theprogrammers to build the software that would calculate the profit things.

    Here your job is to calculate thebusiness profit for a solid sphere. A businessman buys a complete sphere and tomaximize his profit he divides it in n equal parts. All cut should gothrough the axis of the sphere. And every part should look like the picturebelow:

    Input

    You are given a sequence ofintegers N (0 < N < 231), indicating the numbers of parts ofthe sphere. The input file is terminated with a negative number. This numbershould not be processed.

     

    Output

    Calculate the profit over the sold pieces. The resultshould be in percentage and rounded to the nearest integer.

      

    Sample input

    2

    2

    -1

     

    Sampleoutput

    50%

    50%


    题意: 我简单的说, 把球切拿去切, (按图中所示切 不要乱切哦)

    然后问, 表面积比原先的表面积多出了百分之多少?


    做法: 看别人的题解, 发现公式是: (n*25)%

    除了n = 1时, 答案是 0%


    注意点: n * 25 会超, 用long long


    AC代码

    #include<stdio.h>
    
    long long n;
    char ch = '%';
    int main() {
        while(scanf("%lld", &n) != EOF) {
            if(n < 0)
                break;
            if(n == 1)
                printf("0%c", ch);
            else
                printf("%lld%c", 25 * n, ch);
            printf("
    ");
        }
        return 0;
    }
  • 相关阅读:
    链表补充及链表和数组的区别
    单链表(不带头结点)
    动态数组
    【笔记】SQL语言的设计与编写
    netty 学习笔记一:感受 IO编程 NIO编程 与 Netty 编程
    分享系列——Thread#join() 在 Java 源码中并没有 notify ,被阻塞线程是如何唤醒的?答案在 JVM
    RabbitMQ 安装 图笔记版
    RabbitMQ 安装——RPM 和 TAR 两种方式
    学原理脱坑 之 centos 6/7 更新 UTC 以及 设置系统时区
    数据结构和算法篇——散列表
  • 原文地址:https://www.cnblogs.com/pangblog/p/3243897.html
Copyright © 2011-2022 走看看