• 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;
    }
  • 相关阅读:
    MDK中编译程序后Program Size详解
    win10快速访问的文件夹无法删除的解决方法
    stm32类型cl、vl、xl、ld、md、hd的含义
    史上最全软件测试工程师常见的面试题总结(四)【多测师_王sir】
    基于PO和单例设计模式用python+selenium进行ui自动化框架设计【多测师】
    经典的Python编程题【多测师_王sir】
    Java中的泛型【多测师_王sir】【软件测试】
    Java设计模式之单例模式、工厂模式、PO模式【多测师_王sir】
    Java+Selenium做UI自动化中@FindBy和@CacheLookup用法【多测师_王sir】
    postman中接口的入参为图片的处理方式【多测师_王sir】
  • 原文地址:https://www.cnblogs.com/pk28/p/5711721.html
Copyright © 2020-2023  润新知