zoukankan      html  css  js  c++  java
  • Codeforces Gym 100002 B Bricks 枚举角度

    Problem B Bricks"

    Time Limit: 1 Sec  

    Memory Limit: 256 MB

    题目连接

    http://codeforces.com/gym/100002

    Description


    The prisoner of the "IF" castle has decided to run away by disassembling the brick wall in his prison cell. To hide his work from his jailors he shall get rid of the bricks that he removes from the wall. All bricks have a shape of rectangular parallelepiped with the size of A × B × C inches and are so strong that they are impossible to break. However, there's a small rectangular sewer hole in the cell's floor with the size of D × E inches that goes deep down as a rectangular well of the same size (so deep it is, that its depth could not be measured and can be neglected). The prisoner have precisely (up to a tenth of an inch!) measured all the sizes A, B, C, D, E and wants to know if it is possible to dispose of the castle's bricks through the hole in the floor. Please, answer this question for him.

    Input

    The input file consists of a single line with 5 numbers A, B, C, D, and E separated by spaces. A, B, C are the lengths of brick's sides, and D, E are the lengths of hole's sides. All lengths are at least 1 and at most 10 inches and have at most 1 digit after decimal point.

    Output

    Write to the output file a single word YES if it is possible to dispose of the bricks through the hole or NO otherwise.

    Sample Input

    1.0 2.0 1.5 1.4 1.0

    Sample Output

    NO

    HINT

     

    题意

    给你一个无限深矩形的洞和一个立方体,问你这个立方体能否放入这个洞里面

    题解:

    注意可以斜着放

    那就枚举角度往里面塞就行了

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <bitset>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <fstream>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    //freopen("D.in","r",stdin);
    //freopen("D.out","w",stdout);
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 110000
    #define mod 10007
    #define eps 1e-9
    #define pi 3.1415926
    int Num;
    //const int inf=0x7fffffff;   //§ß§é§à§é¨f§³
    const ll Inf=0x3f3f3f3f3f3f3f3fll;
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    //**************************************************************************************
    
    
    double a[3],d,e;
    int flag=0;
    void solve(int x,int y)
    {
        for(double i=0;i<=90;i+=0.001)
        {
            double ttt = i*pi/180;
            double l = a[x]*cos(ttt)+a[y]*sin(ttt);
            double k = a[x]*sin(ttt)+a[y]*cos(ttt);
            if(l<=d&&k<=e)
            {
                cout<<"YES"<<endl;
                flag=1;
                return;
            }
        }
    }
    int main()
    {
        freopen("bricks.in","r",stdin);
        freopen("bricks.out","w",stdout);
        for(int i=0;i<3;i++)
            cin>>a[i];
        cin>>d>>e;
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(i==j)
                    continue;
                solve(i,j);
                if(flag)
                    return 0;
            }
        }
        printf("NO
    ");
    }
  • 相关阅读:
    部署DNS正向解析-使域名和ip互相认识能够友好的访问
    部署NTP时间服务器-使时间同步
    Linux系统中常见的目录名称以及相应内容及用户管理相关文件
    systemctl常用操作
    部署NFS
    配置本地用户模式ftp服务 差个网上的
    js预解析
    jquery 三级联动
    js事件冒泡
    jquery 判断checkbox是否选中
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4782151.html
Copyright © 2011-2022 走看看