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


     

  • 相关阅读:
    关键字驱动测试方法
    File文件操作
    问题处理:类没有复制构造函数
    QTP问题修改:This run was performed on Internet Explorer 7.x without the required 'Enable Tabbed Browsing
    QTP:.net中写文件
    bat垃圾清理
    Lua安装与使用
    QTP:Flight账号及密码
    如何在VS2010中运行控制台程序时停留在控制台显示窗口
    QTP中Screen Recorder无内容,no movie is associated with the results.
  • 原文地址:https://www.cnblogs.com/Jstyle-continue/p/6351932.html
Copyright © 2011-2022 走看看