Lightoj-1072-calm down (find equivalence relationship)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.