-
- Give you a point set that can be divided into several different 2 spaces
- It can be transformed into a set of points that can have several straight lines
- Using the idea of 3-point collinearity to determine the minimum two points of a straight line through gcd
- The ideas and codes of the seniors are used. . .
#include <cstdio> #include <map> #define maxn 1005 using namespace std; inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);} struct Point{ int x,y; Point(){} inline Point(int _x,int _y){ x=_x; y=_y; } inline double lenx(const Point &b)const{ return x-b.x; } inline double leny(const Point &b)const{ return yb.y; } }P[maxn]; int main(){ int n; while(~scanf("%d",&n)){ for(int i=1;i<=n;++i){ int x,y; scanf("%d%d",&x,&y); P[i]=Point(x,y); } int ans=0; for(int i=1;i<=n;++i){ map<pair<int ,int>,int> dp; for(int j=i+1;j<=n;++j){ int x=P[i].lenx(P[j]); int y=P[i].leny(P[j]); int z=gcd(x,y); if(!dp[make_pair(x/z,y/z)])dp[make_pair(x/z,y/z)]=++ans; } } printf("%d\n",ans<<1); } return 0; }
2014 The 5th Shandong Province ACM College Student Programming Competition Painting Cottages
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325519965&siteId=291194637
Ranking