lightoj-1072 - Calm Down(找出等价关系)

Posted FireCool

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lightoj-1072 - Calm Down(找出等价关系)相关的知识,希望对你有一定的参考价值。

1072 - Calm Down
PDF (English) Statistics Forum
Time Limit: 2 second(s) Memory Limit: 32 MB
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.

 

思路:

 

如图可知道:r/(R-r) = sin(360°/n/2); 然后就可以求出r的值

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const double pi = 3.1415926535898;
int main(){
    
    int T,n;
    double R,r,ang;
    scanf("%d",&T);
    for(int t=1;t<=T;t++){
        
        scanf("%lf%d",&R,&n);
        ang = sin(pi/n); //cout<<ang<<endl;
        r = ang*R/(1+ang);
        printf("Case %d: %lf\\n",t,r);
    }
    
    
    return 0;
} 
View Code

 

以上是关于lightoj-1072 - Calm Down(找出等价关系)的主要内容,如果未能解决你的问题,请参考以下文章

(27)How to stay calm when you know you'll be stressed

平常心 stay calm,be patient

version啥意思中文翻译

汉语-词语:沉稳

保持冷静,节制使用 JSON

教大模型自己跳过“无用”层,推理速度×3性能不变,谷歌MIT这个新方法火了...