L - Calm Down(数学几何计算)
2017-10-05 16:57
876 查看
George B. wants to be more than just a good American. He wants to make his daddy proud and become a hero. You know, like Shakib Khan.
But sneaky as he is, he wants a special revolver that will allow him to shoot more often than just the usual six times. This way he can fool and kill the enemy easily (at least that's what he thinks, and that's the best he can think). George has kidnapped
. . . uh, I mean . . . "invited" you and will only let you go if you help him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and 17 bullets):
There is a large circle with radius R and n little circles each having radius
r, are placed inside on the border of the large circle. George wants his bullets to be as large as possible, so there should be no space between the circles. George will decide how large the whole revolver will be and how many bullets it shall
contain. Your job is, given R and n, to compute
r. You have decided to help, because you know that an idiot can't make a revolver even if you help him with the math.
Input
Input starts with an integer T (≤ 125), denoting the number of test cases.
Each case contains a real number R (0 < R < 1000 and contains up to at most two places after the decimal point) and an integer
n (2 ≤ n ≤ 100).
Output
For each test case, print the case number and r in a single line. Errors less than
10-6 will be ignored.
Sample Input
4
4.0 6
4.0 17
3.14 100
42 2
Sample Output
Case 1: 1.3333333333
Case 2: 0.6209067545
Case 3: 0.0956260953
Case 4: 21
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define PI acos(-1.0)
int main()
{
double R,r,n;
int t;
double du;
scanf("%d",&t);
for(int o=1;o<=t;o++)
{
scanf("%lf %lf",&R,&n);
n=n*2;
du=PI*2/n;//求出度 然后求余弦
r=R*sin(du)/(1+sin(du));
printf("Case %d: %.10f\n",o,r) ;
}
return 0;
}
emmmmmm注意的就是
以后PI要这么定义 嗯嗯恩恩恩恩记住
#define PI acos(-1.0)
But sneaky as he is, he wants a special revolver that will allow him to shoot more often than just the usual six times. This way he can fool and kill the enemy easily (at least that's what he thinks, and that's the best he can think). George has kidnapped
. . . uh, I mean . . . "invited" you and will only let you go if you help him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and 17 bullets):
There is a large circle with radius R and n little circles each having radius
r, are placed inside on the border of the large circle. George wants his bullets to be as large as possible, so there should be no space between the circles. George will decide how large the whole revolver will be and how many bullets it shall
contain. Your job is, given R and n, to compute
r. You have decided to help, because you know that an idiot can't make a revolver even if you help him with the math.
Input
Input starts with an integer T (≤ 125), denoting the number of test cases.
Each case contains a real number R (0 < R < 1000 and contains up to at most two places after the decimal point) and an integer
n (2 ≤ n ≤ 100).
Output
For each test case, print the case number and r in a single line. Errors less than
10-6 will be ignored.
Sample Input
4
4.0 6
4.0 17
3.14 100
42 2
Sample Output
Case 1: 1.3333333333
Case 2: 0.6209067545
Case 3: 0.0956260953
Case 4: 21
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define PI acos(-1.0)
int main()
{
double R,r,n;
int t;
double du;
scanf("%d",&t);
for(int o=1;o<=t;o++)
{
scanf("%lf %lf",&R,&n);
n=n*2;
du=PI*2/n;//求出度 然后求余弦
r=R*sin(du)/(1+sin(du));
printf("Case %d: %.10f\n",o,r) ;
}
return 0;
}
emmmmmm注意的就是
以后PI要这么定义 嗯嗯恩恩恩恩记住
#define PI acos(-1.0)
相关文章推荐
- codeforces #320 div 2 C. A Problem about Polyline(计算几何?数学)
- [从头学数学] 第264节 [计算几何] 点和线段
- [从头学数学] 第286节 [计算几何] 多边形的布尔运算(上)
- HDU-5858 Hard problem(数学公式、计算几何)
- nyoj 管道问题 142 (数学计算几何)
- Lightoj1072——Calm Down(计算几何)
- [从头学数学] 第287节 [计算几何] 多边形的布尔运算(中)
- 简单数学题或者计算几何:Codeforces 659D-Bicycle Race
- hdoj 1454&&poj 1039 Pipe 1454 (数学计算几何) 枚举
- [高频] 六.数学,几何计算,位运算常见问题
- [从头学数学] 第266节 [计算几何] 多线段求交点
- [从头学数学] 第269节 [计算几何] 点在多边形内
- [从头学数学] 第280节 [计算几何] 路径合并
- [从头学数学] 第282节 [计算几何] 相邻边和相邻点
- [从头学数学] 第288节 [计算几何] 多边形的布尔运算(下)
- hdoj Intersection 5120 (数学计算几何) 求两个相交圆的面积
- [从头学数学] 第265节 [计算几何] 多线段求交点(扫描线法)
- [从头学数学] 第267节 [计算几何] 路径规划
- [从头学数学] 第270节 [计算几何] 例题数据生成
- [从头学数学] 第272节 [计算几何] 从线段集连通区域