HDU1110 几何

题意:求能否把一个矩形放入另一个矩形中。

只有两种情况 见代码

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<stdlib.h>
 4 #include<math.h>
 5 #include<algorithm>
 6 using namespace std;
 7 const double pi=acos(-1.0);
 8 int main(){
 9     int t;
10     //printf("%lf\n",pi);
11     scanf("%d",&t);
12     while( t-- ){
13         double a,b,x,y;
14         scanf("%lf%lf%lf%lf",&a,&b,&x,&y);
15         if( a<b ) swap( a,b );
16         if( x<y ) swap( x,y );
17         bool flag=false;
18         if( a>x&&b>y )
19             flag=true;
20         else 
21             if( x>=a&&y<b ){
22             double tx,ty;
23             for( double i=0;i<=90;i+=0.1 ){
24                 double cc=i*pi/180.0;
25                 tx=x*cos( cc )+y*sin( cc );
26                 ty=x*sin( cc )+y*cos( cc );
27                 if( tx<a&&ty<b ){
28                     flag=true;
29                     break;
30                 }
31             }
32         }
33         if( flag==true )
34             printf("Escape is possible.\n");
35         else
36             printf("Box cannot be dropped.\n");
37     }
38     return 0;
39 }
keep moving...
原文地址:https://www.cnblogs.com/xxx0624/p/2908639.html