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


     

  • 相关阅读:
    逝者如斯夫(一)
    C#面向对象-多态
    C#基础知识1-深入理解值类型和引用类型
    一个简单的C#爬虫程序
    C# Web分页功能实现
    Web前端JS实现轮播图原理
    visual studio2019 离线MSDN文档安装
    C#中类的修饰符
    HALCON数据类型和C#对应数据类型的对比
    关于HACLON程序导出C#程序,运行报错解决方法
  • 原文地址:https://www.cnblogs.com/Jstyle-continue/p/6351932.html
Copyright © 2011-2022 走看看