zoukankan      html  css  js  c++  java
  • hdu 1110几何题

    应该说是道简单的几何题,可是我推公式还是推了半天,主要就是斜着放的情况吧,刚开始推的公式不对,wa了几次。

    /*
     * hdu1110/win.cpp
     * Created on: 2012-10-24
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    typedef long long LL;
    
    bool judge(double a, double b, double x, double y) {
        if(a * b <= x * y) {
            return false;
        }
        if(x < a && y < b) {
            return true;
        }
        if(b <= y) {
            return false;
        }
        double alpha = atan(x / y);
        double z = sqrt(x * x + y * y);
        double beta = acos(b / z);
        double temp = 2 * y * sin(alpha - beta) + sqrt(z * z - b * b);
        return temp < a;
    }
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        int T, x, y, a, b;
        scanf("%d", &T);
        while(T--) {
            scanf("%d%d%d%d", &a, &b, &x, &y);
            if(a < b) {
                swap(a, b);
            }
            if(x < y) {
                swap(x, y);
            }
            if(judge(a, b, x, y)) {
                puts("Escape is possible.");
            }else {
                 puts("Box cannot be dropped.");
            }
        }
        return 0;
    }
  • 相关阅读:
    分页
    【移动】
    iOS
    内存数据库
    HOJ——T 2275 Number sequence
    HOJ——T 1867 经理的烦恼
    HOJ——T 2430 Counting the algorithms
    洛谷—— P2047 社交网络
    HDU——T 1166 敌兵布阵
    前端学习之jquery
  • 原文地址:https://www.cnblogs.com/moonbay/p/2737121.html
Copyright © 2011-2022 走看看