zoukankan      html  css  js  c++  java
  • Codeforces Round #100 A. New Year Table

    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 ≤ 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

    本人喜欢用余弦定理...

    推公式,选两个相邻的小圆的圆心与大圆圆心连线。然后2*pi/n就是这个角的最小值,然后余弦定理求这个角对应的边的长度与2*r相比

    注意精度  1e-9

    /* ***********************************************
    Author        :guanjun
    Created Time  :2016/7/26 11:34:41
    File Name     :cf100a.cpp
    ************************************************ */
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <stdio.h>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <iomanip>
    #include <list>
    #include <deque>
    #include <stack>
    #define ull unsigned long long
    #define ll long long
    #define mod 90001
    #define INF 0x3f3f3f3f
    #define maxn 10010
    #define cle(a) memset(a,0,sizeof(a))
    const ull inf = 1LL << 61;
    const double eps=1e-9;
    #define pi 4.0*atan(1.0)
    using namespace std;
    priority_queue<int,vector<int>,greater<int> >pq;
    struct Node{
        int x,y;
    };
    struct cmp{
        bool operator()(Node a,Node b){
            if(a.x==b.x) return a.y> b.y;
            return a.x>b.x;
        }
    };
    
    bool cmp(int a,int b){
        return a>b;
    }
    int main()
    {
        #ifndef ONLINE_JUDGE
        //freopen("in.txt","r",stdin);
        #endif
        //freopen("out.txt","w",stdout);
        double n,R,r;
        while(cin>>n>>R>>r){
            if(n==1){
                if(r<=R)puts("YES");
                else puts("NO");
                continue;
            }
            double tmp=(pi/n);
            double c=sin(tmp)*(R-r);
            if(r<=c+eps){
                puts("YES");
            }
            else puts("NO");
    
        }
        return 0;
    }
  • 相关阅读:
    Linux集群之间配置NTP时间同步ntp
    CentOS7安装配置MariaDB(mysql)数据主从同步
    常用邮件SMTP POP3服务器地址大全
    为应用创建多个独立python运行环境
    Linux中安装配置KVM虚拟化
    Linux系统管理和调优(内存、CPU、磁盘IO、网络)
    CentOS8Linux中配置网易云网络yum源安装软件
    CentOS7linux通过http配置共享自动创建yum源的shell脚本
    BigDecimal类型比较数字大小
    Double值保留两位小数的四种方法
  • 原文地址:https://www.cnblogs.com/pk28/p/5711721.html
Copyright © 2011-2022 走看看