uva 10283The Kissing Circles

来源:互联网 发布:mac删除launchpad图标 编辑:程序博客网 时间:2024/05/17 15:20

原题:
There are some interesting figures below. You can see that we can put within a circle one or more circles of equal radius. The important property of these circles is that every consecutive circles touch each other. Given the radius R of the larger circle and the number of small circles N of equal radius inside,you will have to find the radius of the smaller circles r, the area surrounded by the kissing small circles (light blue) I and the area outside the kissing small circles but inside the larger circle (light green) E.
这里写图片描述

Input
The input file will contain several lines of inputs. Each line contains non-negative integers R (R ≤
10000) and N (1 ≤ N ≤ 100) as described before. Input is terminated by end of file.
Output
For each line of input produce one line of output. This one line contains three floating point numbers
r, I and E as described before. The floating point numbers should have ten digits after the decimal
point. The output will be checked with special correction programs. So you wont have to worry about
small precision errors.
Sample Input
10 3
10 4
10 5
10 6

Sample Output

4.6410161514 3.4732652470 107.6854162259
4.1421356237 14.7279416563 83.8264899217
3.7019190816 29.7315551092 69.1625632742
3.3333333333 45.6568837582 59.0628713615

中文:
给你一个大圆的半径,然后再给你小圆的个数。问你按照如图的方式摆放后小圆的半径是多少,小圆所包围的中间区域面积是多少,在大圆中,除去小圆面积和中间的面积后剩下多少?

#include<bits/stdc++.h>using namespace std;double R;double n;int main(){    ios::sync_with_stdio(false);    double pi=acos(-1.0);    while(cin>>R>>n)    {        if(n==1)        {            cout<<fixed<<setprecision(10)<<R<<" "<<0.0<<" "<<0.0<<endl;            continue;        }        double Area=pi*R*R;        double r=R*sin(pi/n)/(sin(pi/n)+1);        double area=pi*r*r*n;        double cen=(n*r*r/tan(pi/n)-((n-2)/2)*pi*r*r);        cout<<fixed<<setprecision(10)<<r<<" "<<cen<<" "<<Area-area-cen<<endl;    }    return 0;}

解答:

高中题目,利用大圆半径和角度关系就能得到小圆半径,剩下的以此算出即可。