日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

POJ 1380 坐标旋转

發(fā)布時間:2023/11/30 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POJ 1380 坐标旋转 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題意:

問第二個矩形能不能放進(jìn)第一個矩形中。

?

題解:

暴力旋轉(zhuǎn)第二個矩形,判斷左右、上下是否同時小于第一個矩形

當(dāng)然,數(shù)學(xué)推導(dǎo)也可以,挺簡單的相似神馬的胡搞就行~

?

View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 #include <cmath> 7 8 #define PI 3.141592653589793 9 #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(x>EPS) 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.x=a.x*sin(hd)-a.y*cos(hd); 29 c.y=a.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 du=0.0;PO c; 37 while(du*2<PI) 38 { 39 c=rotate(sma,du); 40 c.x+=2.0*sma.y*cos(du); 41 if(doublecmp(big.x-c.x)>=0&&doublecmp(big.y-c.y)>=0) return true; 42 if(doublecmp(big.y-c.x)>=0&&doublecmp(big.x-c.y)>=0) return true; 43 du+=0.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 }

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/proverbs/archive/2013/02/24/2924591.html

總結(jié)

以上是生活随笔為你收集整理的POJ 1380 坐标旋转的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。