• Codeforces Round #100 A. New Year Table 几何精度


    http://codeforces.com/group/5pcxnzwAHv/contest/140/problem/A

    A. New Year Table
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Gerald is setting the New Year table. The table has the form of a circle; its radius equals R. Gerald invited many guests and is concerned whether the table has enough space for plates for all those guests. Consider all plates to be round and have the same radii that equal r. Each plate must be completely inside the table and must touch the edge of the table. Of course, the plates must not intersect, but they can touch each other. Help Gerald determine whether the table is large enough for n plates.

    Input

    The first line contains three integers n, R and r (1 ≤ n ≤ 100, 1 ≤ r, R ≤ 1000) — the number of plates, the radius of the table and the plates' radius.

    Output

    Print "YES" (without the quotes) if it is possible to place n plates on the table by the rules given above. If it is impossible, print "NO".

    Remember, that each plate must touch the edge of the table.

    Examples
    input
    4 10 4
    output
    YES
    input
    5 10 4
    output
    NO
    input                                          
    1 10 10
    output                                                            
    YES
    Note

    The possible arrangement of the plates for the first sample is:

    题意:求在一个半径为R的圆里面,能放多少个小圆,每个圆应该紧挨大圆边。

    题解:过大圆圆心作小圆切线,得出三角形,每个三角形的圆心角为pi/n,然后正弦定理求出r/(R-r)=sin(pi/n)。求出r1,和题目的r进行比较,当r1大于或等于r时,才能YES。注意精度。

    几何精度问题参考:http://www.cnblogs.com/crazyacking/p/4668471.html

    注意#define pi acos(-1.0),acos(d)中,d为弧度,不是角度!

     1 #include <stdio.h>
     2 #include<cmath>
     3 #include <string.h>
     4 #include <queue>
     5 #include<iostream>
     6 #include<algorithm>
     7 using namespace std;
     8 const double PI=acos(-1.0);
     9 const double eps=1e-9;
    10 main()
    11 {
    12     int n,R,r;
    13     scanf("%d%d%d",&n,&R,&r);
    14     if(n==1)
    15     puts(r<=R?"YES":"NO");
    16     else if(n==2)
    17     puts(r*2<=R?"YES":"NO");
    18     else
    19     {
    20         double x=PI/n;
    21         double r1=R*sin(x)/(1+sin(x));
    22         puts(r<=r1+eps?"YES":"NO");
    23     }
    24 }
     
  • 相关阅读:
    VMWare上的ubuntu系统安装VMWare Tools(图文)
    Ubuntu添加新分区
    emacs入门
    SQL UNION 操作符
    eclipse安装其他颜色主题包
    mysql左连接
    不能用notepad++编辑器编写python
    ImportError: No module named simplejson.scanner
    运行 python *.py 文件出错,如:python a.py
    doc命令大全(详细版)
  • 原文地址:https://www.cnblogs.com/CrazyBaby/p/5711393.html
Copyright © 2020-2023  润新知