网站建设 技术,网站建设技术问题,站长工具在线,盘锦威旺做网站建设公司题意#xff1a; 问第二个矩形能不能放进第一个矩形中。 题解#xff1a; 暴力旋转第二个矩形#xff0c;判断左右、上下是否同时小于第一个矩形 当然#xff0c;数学推导也可以#xff0c;挺简单的相似神马的胡搞就行~ View Code 1 #include iostream2 #include…题意 问第二个矩形能不能放进第一个矩形中。 题解 暴力旋转第二个矩形判断左右、上下是否同时小于第一个矩形 当然数学推导也可以挺简单的相似神马的胡搞就行~ View Code 1 #include iostream2 #include cstdio3 #include cstring4 #include cstdlib5 #include algorithm6 #include cmath7 8 #define PI 3.1415926535897939 #define EPS 1e-7
10
11 using namespace std;
12
13 struct PO
14 {
15 double x,y;
16 }sma,big;
17
18 inline int doublecmp(double x)
19 {
20 if(xEPS) return 1;
21 else if(x-EPS) return -1;
22 return 0;
23 }
24
25 inline PO rotate(PO a,double hd)
26 {
27 PO c;
28 c.xa.x*sin(hd)-a.y*cos(hd);
29 c.ya.x*cos(hd)a.y*sin(hd);
30 return c;
31 }
32
33 inline bool go()
34 {
35 scanf(%lf%lf%lf%lf,big.x,big.y,sma.x,sma.y);
36 double du0.0;PO c;
37 while(du*2PI)
38 {
39 crotate(sma,du);
40 c.x2.0*sma.y*cos(du);
41 if(doublecmp(big.x-c.x)0doublecmp(big.y-c.y)0) return true;
42 if(doublecmp(big.y-c.x)0doublecmp(big.x-c.y)0) return true;
43 du0.002;
44 }
45 return false;
46 }
47
48 int main()
49 {
50 int cas; scanf(%d,cas);
51 while(cas--)
52 {
53 if(go()) printf(Escape is possible.\n);
54 else printf(Box cannot be dropped.\n);
55 }
56 return 0;
57 } 转载于:https://www.cnblogs.com/proverbs/archive/2013/02/24/2924591.html