POJ 1118
#include<iostream>
#include<set>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#define MAXN 705
using namespace std; int num;
double p[MAXN][];
double a[MAXN*MAXN];
set<int> coll;
set<int>::iterator pos;
multiset<int> coll_main;
int main()
{
//freopen("acm.acm","r",stdin);
int i;
int max;
int j;
int k;
int t;
double value;
int num;
double s2;
while()
{
scanf("%d",&num);
if(num == )
break;
max = ; for(i = ; i < num; ++ i)
{
scanf("%lf%lf",&p[i][],&p[i][]);
}
for(i = ; i < num; ++ i)
{
k = ;
for(j = ; j < num; ++ j)
{
if(i != j)
{
value = (p[i][] - p[j][]) / (p[i][] - p[j][]);
a[k] = value;
++ k;
}
}
//////////////////////////////////////
sort(a,a + k);
s2 = a[];
j = ; for(t = ; t < k; ++ t)
{
if(a[t] == s2)
++ j;
else
{
if(j > max)
{
max = j;
}
s2 = a[t];
-- t;
j = ;
}
}
if(j > max)
max = j;
// cout<<max<<endl; //while(1)
//{
// if(i*(i-1) == 2*max)
// {
// cout<<i<<endl;
// break;
// }
// ++ i;
//}
}
++max;
// cout<<max<<"======="<<endl;
//cout<<int((1+(int)(sqrt(long double(1+8*max))+0.5))/2.0)<<endl;
cout<<max<<endl;
}
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 1118的更多相关文章
- HDU 1432 Lining Up (POJ 1118)
枚举,枚举点 复杂度为n^3. 还能够枚举边的,n*n*log(n). POJ 1118 要推断0退出. #include<cstdio> #include<cstring> ...
- 【同一直线最多点】 poj 1118+2606+2780
poj 1118 #include<iostream> using namespace std; #define N 700 struct point {int x,y;} pnt[N]; ...
- POJ 1118 Lining Up 直线穿过最多的点数
http://poj.org/problem?id=1118 直接枚举O(n^3) 1500ms能过...数据太水了...这个代码就不贴了... 斜率排序O(n^2logn)是更好的做法...枚举斜率 ...
- poj 1118 Lining Up(水题)
再思考一下好的方法,水过,数据太弱! 本来不想传的! #include <iostream> using namespace std; #define MAX 702 /*284K 422 ...
- POJ 1118 Lining Up
枚举,排序. 先将所有点按双关键字排序,然后枚举线的顶点$P$,剩余的点以$P$为中心进行极角排序,可以取个$gcd$,这样一样的点就排在一起了,然后统计一下更新答案. #pragma comment ...
- UVa 270 & POJ 1118 - Lining Up
题目大意:给一些点,找出一条直线使尽可能多的点在这条直线上,求这条直线上点的个数. 以每一个点为原点进行枚举,求其它点的斜率,斜率相同则说明在一条直线上.对斜率排序,找出斜率连续相等的最大长度. #i ...
- POJ 1118 求平面上最多x点共线
题意:给你n个点的坐标.求一条直线最多能穿过多少个点. 思路:枚举(n^2)+求斜率+排序 (复杂度n^2logn)大功告成 //By: Sirius_Ren #include <cmath&g ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
随机推荐
- 第五章:动词(Les verbes)
★及物动词(Les verbes transitifs) 主语发出的动作作用于人或物,它又分为两类,直接及物动词和间接及物动词. ()直接及物动词:动词直接带宾语,不需要介词引导.如: ...
- java.lang.ExceptionInInitializerError Caused by: org.hibernate.InvalidMappingException: Unable to read XML
此错误是说无法读取你的xml文档,于是我们就该去更改xml文档,因为我是自动生成的,所以我找了一份之前手写的,发现是dtd错了,把之前的dtd拷贝过来之后程序就测试通过了
- QGIS 2014年7月18日版本
4. Building on Windows 4.1. Building with Microsoft Visual Studio This section describes how to buil ...
- PAT甲 1032. Sharing (25) 2016-09-09 23:13 27人阅读 评论(0) 收藏
1032. Sharing (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To store Engl ...
- Gridview的RowDataBound事件可以做很多事情
protected void gvTest_RowDataBound(object sender, GridViewRowEventArgs e) { //如果是绑 ...
- delphi TStringList 用法详解
转自: http://blog.163.com/you888@188/blog/static/67239619201472365642633/ delphi TStringList 用法详解 2014 ...
- 面向对象编程思想(前传)--你必须知道的javascript(转载)
原文地址:http://www.cnblogs.com/zhaopei/p/6623460.html阅读目录 什么是鸭子类型 javascript的面向对象 封装 继承 多态 原型 this指向 ...
- CentOS 7 安装MySQL 8.0.11
1. 下载安装包 wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.13-1.el7.x86_64.rpm-bundle.tar 下载 ...
- Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization【转】
https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Proto ...
- 排序算法之快速排序(Quicksort)解析
一.快速排序算法的优点,为什么称之为快排? Quicksort是对归并排序算法的优化,继承了归并排序的优点,同样应用了分治思想. 所谓的分治思想就是对一个问题“分而治之”,用分治思想来解决问题需要两个 ...