UVa 270 & POJ 1118

  题目大意:给一些点,找出一条直线使尽可能多的点在这条直线上,求这条直线上点的个数。

  以每一个点为原点进行枚举,求其它点的斜率,斜率相同则说明在一条直线上。对斜率排序,找出斜率连续相等的最大长度。

 1 #include <cstdio>
 2 #include <cmath>
 3 #include <algorithm>
 4 using namespace std;
 5 #define MAXN 700+10
 6 #define PRECISION 10e-9
 7 
 8 struct Point
 9 {
10     int x, y;
11 };
12 
13 Point point[MAXN];
14 double slope[MAXN];
15 
16 int main()
17 {
18 #ifdef LOCAL
19     freopen("in", "r", stdin);
20 #endif
21     int N;
22     scanf("%d", &N);
23     char s[100];
24     getchar();
25     gets(s);
26     while (N--)
27     {
28         int n = 0; // the number of points
29         while (gets(s))
30         {
31             if (s[0] == '