10499 - The Land of Justice
来源:互联网 发布:阿里云 ecs 流量收费 编辑:程序博客网 时间:2024/04/30 03:19
Problem H
The Land of Justice
Input: standard input
Output: standard output
Time Limit: 4 seconds
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 mathematicians.
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.
Sample input
2
2
-1
Sample output
50%
50%
大意就是,将球切成N块之后,增加了多少表面积,用百分比来表示。
一开始没有考虑到数据范围的问题,N是int的,可是25*N不一定是int类型。
之后还有就是N=1的时候,相当于没有切块,所以答案应该是0%
#include<iostream>#include<cstdio>#include<cmath>#include<cstring>#include<string>#include<ctype.h>#include<algorithm>#include<queue>#include<stack>using namespace std;int main (){ long long n,p; while(cin>>n) { if (n<0) break; else if (n==1) cout<<"0%"<<endl; else { p=floor((n)/4.0*100); cout<<p<<"%"<<endl; } } return 0;}
- 10499 - The Land of Justice
- 10499 - The Land of Justice
- 10499 - The Land of Justice
- 10499 - The Land of Justice
- The Land of Justice
- The Land of Justice
- The Land of Justice
- uva 10499 - The Land of Justice
- uva-10499 - The Land of Justice
- UVa 10499 - The Land of Justice
- UVa 10499 - The Land of Justice
- UVA 10499 The Land of Justice
- uva 10499 - The Land of Justice
- uva 10499 The Land of Justice
- UVA 10499 The Land of Justice
- UVa 10499 - The Land of Justice
- UVa 10499 - The Land of Justice
- Uva 10499 The Land of Justice
- hdu 1258 Sum It Up(DFS)
- JavaMail API – Sending Email Via Gmail SMTP Example
- 优先队列及重载的使用
- cxf-rs在单独felix或equinox中的部署
- 分享android开发过程中用到的一些开源框架
- 10499 - The Land of Justice
- 获得图片位置 时间 信息
- jsoup解析html中的<select>标签
- 【jiasuba】关闭快捷应用程序的几种小技巧
- 在ArcMap地图文档中使用ArcGIS Online的位置服务定位器
- linux文件分享有关的命令
- ICE的5个服务
- Inventor 2014不再支持VBA自动宏
- cocos2d-x-2.1.4 通过create_project.py创建项目