• POJ 1380 Equipment Box (暴力枚举)


    Equipment Box

    题目链接:

    http://acm.hust.edu.cn/vjudge/contest/130510#problem/B

    Description

    There is a large room in the Pyramid called Room-of-No-Return. Its floor is covered by rectangular tiles of equal size. The name of the room was chosen because of the very high number of traps and mechanisms in it. The ACM group has spent several years studying the secret plan of this room. It has made a clever plan to avoid all the traps. A specially trained mechanic was sent to deactivate the most feared trap called Shattered Bones. After deactivating the trap the mechanic had to escape from the room. It is very important to step on the center of the tiles only; he must not touch the edges. One wrong step and a large rock falls from the ceiling squashing the mechanic like a pancake. After deactivating the trap, he realized a horrible thing: the ACM plan did not take his equipment box into consideration. The box must be laid onto the ground because the mechanic must have both hands free to prevent contact with other traps. But when the box is laid on the ground, it could touch the line separating the tiles. And this is the main problem you are to solve.

    Input

    The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case consists of a single line. The line contains exactly four integer numbers separated by spaces: A, B, X and Y. A and Bindicate the dimensions of the tiles, X and Y are the dimensions of the equipment box (1 <= A,B,X,Y <= 50000).

    Output

    Your task is to determine whether it is possible to put the box on a single tile -- that is, if the whole box fits on a single tile without touching its border. If so, you are to print one line with the sentence "Escape is possible.". Otherwise print the sentence "Box cannot be dropped.".

    Sample Input

    ``` 2 10 10 8 8 8 8 10 10 ```

    Sample Output

    ``` Escape is possible. Box cannot be dropped. ```

    Source

    2016-HUST-线下组队赛-5
    ##题意: 判断一个小矩形能否放入一个大矩形.
    ##题解: 横着和竖着的情况很容易判断. 关键在于斜着放的情况:可以直接暴力枚举小矩形的旋转角. 数据量比较大,一开始用0.01的差值T掉了.
    ##代码: ``` cpp #include #include #include #include #include #include #include #include #include #include #define maxn 101000 #define inf 0x3f3f3f3f #define pi acos(-1.0) #define mod 1000000007 #define mid(a,b) ((a+b)>>1) #define IN freopen("in.txt","r",stdin); using namespace std;

    int a,b,A,B;
    bool solve() {
    for(double arg=0; arg<=90.0; arg+=0.1) {
    double p = argpi / 180.0;
    double t1 = b
    sin(p) + acos(p);
    double t2 = a
    sin(p) + b*cos(p);
    if(t1 < A && t2 < B) return 1;
    }
    return 0;
    }

    int main()
    {
    //IN;

    int T;
    cin >> T;
    while (T--){
        scanf("%d %d %d %d",&A,&B,&a,&b);
        if(A > B) swap(A,B);
        if(a > b) swap(a,b);
    
        bool flag = 0;
        if(a < A && b < B) flag = 1;
    
        if(solve()) flag = 1;
    
        if(flag) printf("Escape is possible.
    ");
        else printf("Box cannot be dropped.
    ");
    }
    
    return 0;
    

    }

  • 相关阅读:
    MT【274】一道漂亮的不等式题
    MT【273】2014新课标压轴题之$ln2$的估计
    MT【272】更大的视野,更好的思路.
    MT【271】一道三角最值问题
    MT【270】含参绝对值函数最大之二
    MT【269】含参函数绝对值最大
    MT【268】投篮第一次很重要
    国内下载Git的连接地址
    django 取model字段的verbose_name值
    Django报错(NoReverseMatch at /admin/)
  • 原文地址:https://www.cnblogs.com/Sunshine-tcf/p/5816375.html
Copyright © 2020-2023  润新知