zoukankan      html  css  js  c++  java
  • poj1118

    简单题

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <cmath>
    #include
    <algorithm>
    using namespace std;

    #define maxn 705
    #define eps 10E-9

    struct Point
    {
    int x, y;
    } point[maxn];

    struct Node
    {
    double k;
    int a, b;
    } f[maxn
    * maxn];

    int n, ncount;
    double inf;

    bool operator <(const Point &a, const Point &b)
    {
    return (a.x == b.x && a.y < b.y) || a.x < b.x;
    }

    bool operator <(const Node &a, const Node &b)
    {
    if (abs(a.k - b.k) > eps)
    return a.k < b.k;
    return (a.a == b.a && a.b < b.b) || a.a < b.a;
    }

    double cal(Point &a, Point &b)
    {
    if (a.x == b.x)
    return inf;
    return (b.y - a.y) * 1.0 / (b.x - a.x);
    }

    int main()
    {
    inf
    = 1.79769e+308;
    //freopen("t.txt", "r", stdin);
    while (scanf("%d", &n), n)
    {
    for (int i = 0; i < n; i++)
    scanf(
    "%d%d", &point[i].x, &point[i].y);
    sort(point, point
    + n);
    ncount
    = 0;
    for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
    {
    f[ncount].a
    = i;
    f[ncount].b
    = j;
    f[ncount].k
    = cal(point[i], point[j]);
    ncount
    ++;
    }
    sort(f, f
    + ncount);
    int len = 1;
    int ans = 0;
    for (int i = 1; i < ncount; i++)
    {
    if (f[i].a == f[i - len].a && abs(f[i].k - f[i - len].k) < eps)
    len
    ++;
    else
    {
    ans
    = max(ans, len);
    len
    = 1;
    }
    }
    printf(
    "%d\n", ans + 1);
    }
    return 0;
    }

  • 相关阅读:
    bootstrap里的下拉菜单
    bootstrap里的图标
    bootstrap
    maven和svn区别
    maven
    计算机程序的思维逻辑 (20)
    计算机程序的思维逻辑 (19)
    计算机程序的思维逻辑 (18)
    计算机程序的思维逻辑 (17)
    计算机程序的思维逻辑 (15)
  • 原文地址:https://www.cnblogs.com/rainydays/p/2097161.html
Copyright © 2011-2022 走看看