码迷,mamicode.com
首页 > 其他好文 > 详细

uva 10499 The Land of Justice

时间:2015-07-06 14:20:50      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:uva10499

In the Land of Justice the selling price of everything is fixed all over the country. Nobody can buy a thing and sell it in double price. But, that created problems for the businessmen. They left their business and went to the production. So, after some days everybody was in production and nobody in business. And the people didn’t get their necessary things though the country was self-sufficient in every sector. The government became very much anxious. But, they were intelligent enough to call the mathe- maticians. The mathematicians gave a solution. They suggested setting the surface area of an object as its selling-unit instead of its volume. Actually the clever mathematicians were very much interested to establish their own business. Now, the government asks the programmers to build the software that would calculate the profit things. Here your job is to calculate the business profit for a solid sphere. A businessman buys a complete sphere and to maximize his profit he divides it in n equal parts. All cut should go through the axis of the sphere. And every part should look like the picture below:
Input
You are given a sequence of integers N (0 < N < 231), indicating the numbers of parts of the sphere. The input file is terminated with a negative number. This number should not be processed.
Output
Calculate the profit over the sold pieces. The result should be in percentage and rounded to the nearest integer.
Universidad de Valladolid OJ: 10499 – The Land of Justice 2/2
Sample Input
2
2
-1
Sample Output
50%
50%

/*
Author:ZCC;
Solve:题目的意思是把球经过直径分成N块均等的,那么表面积的增加量与原来的面积
比是多少,球的表面积是4*PI*R^2 ,增加的是N*2*(PI*R*R)/2=N*PI*R*R ,==>N/4为答案
*/


using namespace std;
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<cstring>
#include<string>

const int maxn=55;
typedef long long LL;

int main(){
    #ifndef ONLINE_JUDGE
    ///freopen("Text//in.txt","r",stdin);
    #endif // ONLINE_JUDGE
    int n;
    while(~scanf("%d",&n)&&n>=0){
        if(n==1){
            puts("0%");
        }
        else {
            printf("%.0lf%%\n",25.0*(double)n);
        }
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

uva 10499 The Land of Justice

标签:uva10499

原文地址:http://blog.csdn.net/u013167299/article/details/46772805

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!