zoukankan      html  css  js  c++  java
  • poj2780

    同2606

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

    #define eps 1.0e-8
    #define maxn 1005

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

    struct Line
    {
    int a, b;
    double k;
    bool end;
    } line[maxn * maxn];

    int n, ncount;

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

    double getk(XPoint &a, XPoint &b)
    {
    return (b.y - a.y) * 1.0 / (b.x - a.x);
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    while (~scanf("%d", &n))
    {
    ncount = 0;
    for (int i = 0; i < n; i++)
    scanf("%d%d", &point[i].x, &point[i].y);
    for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++)
    {
    line[ncount].a = i;
    line[ncount].b = j;
    if (point[i].x == point[j].x)
    line[ncount].end = true;
    else
    {
    line[ncount].end = false;
    line[ncount].k = getk(point[i], point[j]);
    }
    ncount++;
    }
    sort(line, line + ncount);
    int start = 0;
    int ans = 0;
    for (int i = 1; i < ncount; i++)
    {
    if (!((line[i].end && line[start].end) || ((!line[i].end && !line[start].end) && (line[i].k - line[start].k) < eps)) || line[i].a != line[start].a)
    {
    start = i;
    continue;
    }
    if (i - start > ans)
    {
    ans = i - start;
    }
    }
    printf("%d\n", ans + 2);
    }
    return 0;
    }

  • 相关阅读:
    IIS中使用URL重写工具进行rewrite的规则示例
    施文钧:值得看的文化类节目
    泉州校区/院区分布趋势
    IIS安装SSL证书-轻松实现HTTPS
    [小结]定时任务/作业
    技术或运营的妥协/退让场景
    Windows下开发PHP的准备事项
    移动端之封装个tap()事件
    注解
    Intellij IDEA run coverage之覆盖率测试
  • 原文地址:https://www.cnblogs.com/rainydays/p/2199773.html
Copyright © 2011-2022 走看看