UVALive 6618 Skycity(数学)
2016-07-30 23:23
323 查看
思路:一开始写二分边数一直WA到无法自理...对于给定的圆,和他相切的正多边形的边数越多,正多边形的周长越小。但是因为对每个边长有最小的长度限制,我们可以直接算出来。利用边长的最小限制,我们能求出对应的内角,从而可以找到大于等于该内角度数的边数最小的正多边形。(摘自网上)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
double R , r , H , F , S;
const double pi = acos(-1.0);
int main()
{
while (scanf("%lf%lf%lf%lf%lf",&R , &r , &H , &F , &S)!=EOF)
{
double ans = 0;
double height = 1.0*H/F;
double d = (R-r)/F;
for(int i = 0;i<(int)F;i++)
{
double dr = r+i*d;
int bianshu = pi/atan(S/2.0/height/dr);
ans+=bianshu*2.0*dr*tan(pi/bianshu)*height;
}
printf("%.3lf\n",ans);
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
double R , r , H , F , S;
const double pi = acos(-1.0);
int main()
{
while (scanf("%lf%lf%lf%lf%lf",&R , &r , &H , &F , &S)!=EOF)
{
double ans = 0;
double height = 1.0*H/F;
double d = (R-r)/F;
for(int i = 0;i<(int)F;i++)
{
double dr = r+i*d;
int bianshu = pi/atan(S/2.0/height/dr);
ans+=bianshu*2.0*dr*tan(pi/bianshu)*height;
}
printf("%.3lf\n",ans);
}
return 0;
}
相关文章推荐
- UVALive 7040 Color (容斥原理 + 组合数学递推公式 + 求逆元 + 基础数论)
- UVaLive 7359 Sum Kind Of Problem (数学,水题)
- 4000 UVALive - 6862 Triples(数学分析)
- UVALive 7511 Multiplication Table (数学模拟题)
- UVALive 3720 Highways 组合数学
- UVALive 7040 Color 容斥原理 + 组合数学递推公式 +lucas
- Robot Race UVALive - 7020(几何数学 判断钝角)
- 【UVALive】2145 - Lost in Space(数学)
- UVALive 7267(数学暴力)
- UVALive5520 UVA305 POJ1012 HDU1443 Joseph【数学计算+打表+水题】
- UVALive 6918 And Or 数学二进制+枚举
- UVALive2287 POJ1047 HDU1313 ZOJ1073 Round and Round We Go【大数+数学计算+水题】
- UVALive 7147-World Cup-数学推导-水题
- Yukari's Birthday(UVALive - 6076)枚举 数学
- UVALive 5070 Awkward Lights 数学 高斯消元
- UVA264 UVALive5373 UVALive3034 Count on Cantor【数学】
- The queue uvalive 5002 light 1382 uva 12257 (dfs加组合数学)
- UVALive 7040 Color (容斥原理 + 组合数学递推公式 + 求逆元 + 基础数论)
- UVALive 5058 Counting BST 数学
- UVALive 6469 Deranged Exams 组合数学+容斥原理