POJ 1106 Transmitters(计算几何)
生活随笔
收集整理的這篇文章主要介紹了
POJ 1106 Transmitters(计算几何)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目鏈接
切計(jì)算幾何,感覺(jué)計(jì)算幾何的算法還不熟。此題,枚舉線段和圓點(diǎn)的直線,平分一個(gè)圓
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <cmath> 6 using namespace std; 7 #define eps 1e-8 8 struct point 9 { 10 double x,y; 11 }p[201]; 12 double dis(point p1,point p2) 13 { 14 return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); 15 } 16 double xmult(point p1,point p2,point p0) 17 { 18 return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y); 19 } 20 int main() 21 { 22 point r; 23 double d; 24 int n,m,i,j,ans,temp; 25 while(scanf("%lf%lf%lf",&r.x,&r.y,&d)!=EOF) 26 { 27 if(d < 0) break; 28 scanf("%d",&n); 29 m = 0; 30 for(i = 0;i < n;i ++) 31 { 32 scanf("%lf%lf",&p[i].x,&p[i].y); 33 } 34 for(i = 0;i < n;i ++) 35 { 36 if(dis(p[i],r) > d) 37 continue; 38 p[m++] = p[i]; 39 } 40 ans = 0; 41 for(i = 0;i < m;i ++) 42 { 43 temp = 0; 44 for(j = 0;j < m;j ++) 45 { 46 if(xmult(p[i],p[j],r) >= 0) 47 temp ++; 48 } 49 ans = max(ans,temp); 50 } 51 printf("%d\n",ans); 52 } 53 return 0; 54 }?
。
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/naix-x/p/3363630.html
總結(jié)
以上是生活随笔為你收集整理的POJ 1106 Transmitters(计算几何)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mac 下launchpad超级慢的问题
- 下一篇: HDOJ 1071 The area (