# bzoj 1610: [Usaco2008 Feb]Line连线游戏

23333，求出有多少斜率就好（还有斜率不存在），map随便搞一搞233333

 1 #include<cstdio>
2 #include<cstring>
3 #include<cmath>
4 #include<map>
5 #define N 100005
6 #define inf 0x3f3f3f3f
7 #define eps 1e-8
8 using namespace std;
9 inline int ra()
10 {
11     int x=0,f=1; char ch=getchar();
12     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
13     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
14     return x*f;
15 }
16 int x[1005],y[1005],n,ans;
17 map<double , bool > mp;
18 int main()
19 {
20     n=ra();
21     for (int i=1; i<=n; i++) x[i]=ra(),y[i]=ra();
22     for (int i=1; i<=n; i++)
23         for (int j=1; j<=n; j++)
24             if (i!=j)
25             {
26                 if (x[i]-x[j]!=0)
27                 {
28                     if (mp[(double)(y[j]-y[i])/(x[j]-x[i])]==0) mp[(double)(y[j]-y[i])/(x[j]-x[i])]=1,ans++;
29                 }
30                 else if (!mp[1e9+7]) mp[1e9+7]=1,ans++;
31             }
32     printf("%d",ans);
33     return 0;
34 }

posted @ 2017-02-28 20:49  ws_ccd  阅读(89)  评论(0编辑  收藏  举报