zoukankan      html  css  js  c++  java
  • poj 1118 Lining Up 解题报告

    题意:

    给出n个点的整数坐标(n<=700),求一条直线,使得在这条直线上的点数最多,输出点数。

    思路:

    简单几何题。采用几何中三个点是否在一条直线判定定理。

    代码:

    #include <iostream>
    #include
    <algorithm>
    #include
    <cstdio>
    using namespace std;

    typedef
    struct
    {
    int x,y,count;
    }Point;


    Point p[
    703];

    double a[703];

    int main()
    {
    //freopen("input.txt","r",stdin);

    int n;
    while(cin>>n,n)
    {
    int i;
    for(i=0;i<n;i++)
    {
    cin
    >>p[i].x>>p[i].y;

    }
    int temp,max=0;
    for(i=0;i<n;i++)
    {

    for(int j=i+1;j<n;j++)
    {

    temp
    =0;
    for(int k=j+1;k<n;k++)
    {
    int a=(p[i].x-p[k].x)*(p[j].y-p[k].y);
    int b=(p[i].y-p[k].y)*(p[j].x-p[k].x);
    if(a==b) temp++;
    }
    max
    =max>temp?max:temp;
    }
    }

    cout
    <<max+2<<endl;
    }



    return 0;
    }
  • 相关阅读:
    Gym102028L
    CF985G
    三元环 & 四元环计数 学习笔记
    Hall 定理 学习笔记
    CF36E
    CF1110G
    P6071
    可持久化数据结构 学习笔记
    多项式全家桶
    c++ 编译zlib
  • 原文地址:https://www.cnblogs.com/andyidea/p/poj1118.html
Copyright © 2011-2022 走看看