zoukankan      html  css  js  c++  java
  • cf

    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 nR and r (1 ≤ n ≤ 1001 ≤ 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),小圆圆心到大圆圆心为(R-r)。则一个圆占得圆心角为 2*arcsin(r/(R*r))。用2*PI 除以这个圆心角就可以得到最大个数。这题会卡精度问题,wa了N久。以后判断精度在结果加上 1e-12 后进行判断。
    代码:
     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 
     4 int main()
     5 {
     6     double n,R,r;
     7     while(cin>>n>>R>>r){
     8         if(r > R){
     9             cout<<"NO"<<endl;
    10             continue;
    11         }
    12         if(r > R/2){
    13             if(n == 1)  cout<<"YES"<<endl;
    14             else
    15                 cout<<"NO"<<endl;
    16             continue;
    17         }
    18 
    19         double a = asin((double)r/(R-r));
    20 
    21         if(3.1415926535898/a > n)
    22             cout<<"YES"<<endl;
    23         else
    24             cout<<"NO"<<endl;
    25     }
    26     return 0;
    27 }
    View Code


     

  • 相关阅读:
    torchline:让Pytorch使用的更加顺滑
    论文笔记系列-AutoFPN
    Latex: 添加IEEE会议论文作者信息
    Latex citation using natbib and footnotesize
    解决 Boost安装:fatal error: bzlib.h: No such file or directory 问题
    将 Graphviz .dot 文件转换为其他格式的图像
    Mac环境下扩容 .vmdk 镜像容量
    解决 dpkg: warning: files list file for package 'x' missing 问题
    Latex 左右引号
    Latex 三线表及设置列数
  • 原文地址:https://www.cnblogs.com/Jstyle-continue/p/6351932.html
Copyright © 2011-2022 走看看