您的位置:首页 > 其它

UVA 10499 The Land of Justice

2016-07-14 23:02 218 查看

UVA-10499

题意:求且对球体如描述切 n 刀,求总共表面积相对原来的球体增加了多少个百分比。

解题思路:每切一刀都会增加 2 个半圆,增加的面积为 π*r^2,而球体表面积为 4*π*r^2,所以每刀多 25%,但是要注意只切 1 刀不增加。

要用long long ,因为 n 最大有 2^31-1, n*25 会超过int 的范围。

/*************************************************************************
> File Name: UVA-10499.cpp
> Author: Narsh
>
> Created Time: 2016年07月14日 星期四 16时12分55秒
************************************************************************/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
long long r,n;
int main () {
while (cin>>n && n >0 ) {
if (n<2) r=0;
else r = n*25;
cout<<r<<"%"<<endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: