POJ 1799 geometric questions simple and clear questions

Source: Internet
Author: User

Yeehaa!
Time Limit: 1000 MS Memory Limit: 30000 K
Total Submissions: 10275 Accepted: 5181
Description

Background
George B. wants to be more than just a good American. He wants to make his daddy proud and become a western hero. You know, like John Wayne.
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 ).
Problem
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 with radius r that are placed inside on the border of the large circle. george wants his bullets to be as large as possible, so there shoshould 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.
Input

The first line contains the number of scenarios. for each scenario follows a line containing a real number R and an integer n, with 1 <= R <= 100 and 2 <= n <= 100.
Output

The output for every scenario begins with a line ining "Scenario # I:", where I is the number of the scenario starting at 1. then print the value for r, rounded to three decimal places. terminate the output for the scenario with a blank line.
Sample Input

4
4.0 6
4.0 17
3.14159 100
42 2
Sample Output

Scenario #1:
1.333

Scenario #2:
0.621

Scenario #3:
0.096

Scenario #4:
21.000
Source

TUD Programming Contest 2004, Darmstadt, Germany
Question:
Returns the radius of a large circle and the number of small circles in it to find the radius of the small circle.

 

Ideas:
After the center A of A large circle is connected to center B of A small circle, it is connected to the intersection of two small circles to obtain A vertical triangle.

# Include <stdio. h>
# Include <math. h>
Const double PI = acos (-1.0 );
Int main ()
{
Int cas, I, j = 0, n;
Double R, r;
Scanf ("% d", & cas );
While (cas --)
{
J ++;
Scanf ("% lf % d", & R, & n );
Printf ("Scenario # % d: \ n", j );
R = (R * sin (PI/(n * 1.0)/(1 + sin (PI/(n x 1.0 )));
Printf ("%. 3lf \ n", r );
}
Return 0;
}

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.