应该说是道简单的几何题,可是我推公式还是推了半天,主要就是斜着放的情况吧,刚开始推的公式不对,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; }