1072-calm down
PDF (中文版) statisticsforum
Time Limit:2 second (s) Memory limit:32 MB
George B. Wants to is 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 was, he wants a special revolver that would allow him to shoot more often than just the usual six times. This is the He can fool and kill the enemy easily (at least that's what's he thinks, and that's the best he can think). George has kidnapped ... uh, I mean ... "Invited" you and would only let you go if you are him with the math. The piece of the revolver that contains the bullets looks like this (examples for 6 and bullets):
There is a large circle with radius r and N little circles each have radius r, is placed inside on the border of the LA Rge Circle. George wants his bullets to being as large as possible, so there should is no space between the circles. George would decide how large the whole revolver would be is and how many bullets it shall contain. Your job is, given R and N, to compute R. You have decided-to-help, because-know that a 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 < $ and contains up for the most of the 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 'll be ignored.
Ideas:
Can know: r/(r-r) = sin (360°/N/2), then you can find the value of R
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespacestd;Const DoublePI =3.1415926535898;intMain () {intT,n; DoubleR,r,ang; scanf ("%d",&T); for(intt=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 (find equivalence relationship)