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;
    }
  • 相关阅读:
    [POJ1743]Musical Theme
    [HDU5343]MZL's Circle Zhou
    [ZJOI2015]诸神眷顾的幻想乡
    [SDOI2016]生成魔咒
    [POI2000]Repetitions
    [SPOJ-NSUBSTR]Substrings
    [SPOJ-LCS2]Longest Common Substring II
    [SPOJ-LCS]Longest Common Substring
    [SDOI2010]地精部落
    [HNOI2003]消防局的设立
  • 原文地址:https://www.cnblogs.com/moonbay/p/2737121.html
Copyright © 2011-2022 走看看