ural 1052 Rabbit Hunt

http://acm.timus.ru/problem.aspx?space=1&num=1052

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 struct node
 7 {
 8     double x,y;
 9 }p[500];
10 
11 double cross(node a,node b,node c)
12 {
13     return ((c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x));
14 }
15 int main()
16 {
17     int n;
18     scanf("%d",&n);
19     for(int i=0; i<n; i++)
20     {
21         scanf("%lf%lf",&p[i].x,&p[i].y);
22     }
23     int max1=-1;
24     for(int i=0; i<n; i++)
25     {
26         for(int j=i+1; j<n; j++)
27         {
28             int ans=2;
29             for(int k=0; k<n; k++)
30             {
31                 if(i!=k&&j!=k&&cross(p[i],p[j],p[k])==0) ans++;
32             }
33             max1=max(max1,ans);
34         }
35     }
36     printf("%d
",max1);
37     return 0;
38 }
View Code
原文地址:https://www.cnblogs.com/fanminghui/p/3612100.html