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;
    }
  • 相关阅读:
    C语言程序设计_zju——计算时间差
    C语言程序设计_zju——第1周编程练习_逆序的三位数
    常用CMD指令
    C#MVC Razor的Ajax.BeginForm里面的OnSuccess未执行(未成功跳转)
    发布带注释的dll
    读书笔记之《得未曾有》
    读书笔记之《高效人士的七个习惯》
    读书笔记之《好好说话》
    个人随笔之《关于选择》
    个人随笔之《关于心安》
  • 原文地址:https://www.cnblogs.com/pk28/p/5711721.html
Copyright © 2011-2022 走看看