szabivan

EQBOX

Oct 26th, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. inline bool befer( long long a, long long b, long long c, long long d ) {
  8.         if( (c < a) && (d < b) ) return true;
  9.         if( a <= c ) return false;
  10.         long long atlo = c*c + d*d;
  11.         if( atlo >= a*a+b*b ) return false;        
  12.  
  13.         double x = ( b - sqrt(atlo - a*a) );
  14.         double y = ( a - sqrt(atlo - b*b) );
  15.         if( 4.0*c*c > x*x + y*y ) return false;
  16.         return true;
  17. }
  18.  
  19. int main() {
  20.         int t;
  21.         long long a, b, c, d;
  22.         scanf("%d", &t);
  23.         while( t-- ) {
  24.                 scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  25.                 if( b < a ) { std::swap(a,b); }
  26.                 if( d < c ) { std::swap(c,d); }                
  27.                 if( befer(a, b, c, d) ) printf("Escape is possible.\n");
  28.                 else printf("Box cannot be dropped.\n");
  29.         }
  30.         return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment