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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

poj 1106 Transmitters (枚举+叉积运用)

發布時間:2025/5/22 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 poj 1106 Transmitters (枚举+叉积运用) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:http://poj.org/problem?id=1106

?

算法思路:由于圓心和半徑都確定,又是180度,這里枚舉過一點的直徑,求出這個直徑的一個在圓上的端點,就可以用叉積的大于,等于,小于0判斷點在直徑上,左,右。 這里要記錄直徑兩邊的加直徑上的點的個數,去最大的。

?

代碼:

#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std;const double eps = 1e-8; const double PI = acos(-1.0); const double INF = 1000000000000000.000;struct Point{double x,y;Point(double x=0, double y=0) : x(x),y(y){ } //構造函數 }; typedef Point Vector;struct Circle{Point c;double r;Circle() {}Circle(Point c,double r): c(c),r(r) {} }; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);} Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);} Vector operator * (double p,Vector A){return Vector(A.x*p,A.y*p);} Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);}bool operator < (const Point& a,const Point& b){return a.x < b.x ||( a.x == b.x && a.y < b.y); }int dcmp(double x){if(fabs(x) < eps) return 0;else return x < 0 ? -1 : 1; } bool operator == (const Point& a, const Point& b){return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0; }///向量(x,y)的極角用atan2(y,x); inline double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; } inline double Length(Vector A) { return sqrt(Dot(A,A)); } inline double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); } double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; } Vector vecunit(Vector v){ return v / Length(v);} //單位向量 Point read_point(){Point A;scanf("%lf %lf",&A.x,&A.y);return A; }//多邊形 //求面積 double PolygonArea(Point* p,int n){ //n個點double area = 0;for(int i=1;i<n-1;i++){area += Cross(p[i]-p[0],p[i+1]-p[0]);}return area/2; }/*************************************分 割 線*****************************************/int main() {//freopen("E:\\acm\\input.txt","r",stdin); Point O,P[155];double R;while(scanf("%lf %lf %lf",&O.x,&O.y,&R) == 3 && dcmp(R)>0){int N;cin>>N;int cnt = 0;for(int i=1;i<=N;i++){Point temp = read_point();double len = Length(temp-O);if(dcmp(len-R) > 0) continue;P[++cnt] = temp;}int ans = 0;for(int i=1; i<=cnt; i++){if(P[i] == O){ans = max(ans,1);continue;}int lnum = 1;int rnum = 1;Vector v = P[i] - O;v = (-1.0)*vecunit(v);Point T = O + R*v;for(int j=1; j<=cnt; j++){if(i == j) continue;if(dcmp(Cross(P[j]-T,O-T)) > 0 ) lnum++;else if(dcmp(Cross(P[j]-T,O-T)) == 0) lnum++,rnum++;else rnum++;}int num = max(lnum,rnum);ans = max(ans,num);}printf("%d\n",ans);} } View Code

?

轉載于:https://www.cnblogs.com/acmdeweilai/p/3352748.html

總結

以上是生活随笔為你收集整理的poj 1106 Transmitters (枚举+叉积运用)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。