Sunday, December 4, 2016

LightOJ - 1072 - Calm Down

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

Output for Sample Input

4
4.0 6
4.0 17
3.14 100
42 2
Case 1: 1.3333333333
Case 2: 0.6209067545
Case 3: 0.0956260953
Case 4: 21

Solution:

  1. #include <bits/stdc++.h>
  2. #define pb push_back
  3. using namespace std;
  4. typedef long long LL;
  5. const int S = 100003;
  6. const int MOD = 1e9+7;
  7. const double pi = 2 * acos (0.0);
  8. int _Int(){int x; scanf("%d"&x); return x;}
  9. LL _LLi(){LL x; scanf("%lld"&x); return x;}
  10. void pruts(){puts("-1");exit(EXIT_SUCCESS);}
  11. int dirX[] = { 10-101-11-1 };
  12. int dirY[] = { 010-11-1-11 };
  13. int rX[] = { 1122-1-1-2-2 };
  14. int rY[] = { 2-21-12-21-1 };
  15. template < class T > T tri_Area( T x1, T y1, T x2, T y2, T x3, T y3 ){ return abs( x1*( y2-y3 ) - y1*( x2-x3 ) + ( x2*y3-x3*y2 ) );};
  16. template < class T > T Distance( T x1, T y1, T x2, T y2 ){ return sqrt( ( x1-x2 ) * ( x1-x2 ) + ( y1-y2 ) * ( y1-y2 ) ); };
  17. template < class T > T bigMod( T n, T p, T m ){ if( p == 0 )return 1; if( p&1 )return ( n*bigMod( n, p-1, m ) )%m; T x = bigMod( n, p/2, m ); return ( x*)%m; };
  18. int sset(int N, int pos){return N=N|(1<<pos);}
  19. bool check(int N, int pos){return (bool)(N&(1<<pos));}
  20. int reset(int N, int pos){return N=N&~(1<<pos);}
  21. /*******************###########################################********************
  22. ********************##   MD. YA-SEEN ARAFAT(ThunderStroke)   ##********************
  23. ********************##    CSE, University of Asia Pacific    ##********************
  24. ********************###########################################********************/
  25. void Love(){
  26.     int t = _Int(), cs = 0;
  27.     while( t-- ){
  28.         double R, n;
  29.         scanf( "%lf %lf"&R, &);
  30.         double ans = ( sin( pi/) * R ) / ( sin( pi/) + 1 );
  31.         printf( "Case %d: %.8lf\n"++cs, ans );
  32.     }
  33. }
  34. int main(){
  35.     #ifndef ONLINE_JUDGE
  36. //        freopen("in.txt", "r", stdin);
  37. //        freopen("n.txt", "w", stdout);
  38.     #endif
  39.     Love();
  40.     return 0;
  41. }

No comments:

Post a Comment