UVA 270 Lining Up
来源:互联网 发布:惠州惠阳区网络问政 编辑:程序博客网 时间:2024/04/30 10:57
题意:给你n个点,求出能在一条直线上的点的最大值。
Lining Up
``How am I ever going to solve this problem?" said the pilot.
Indeed, the pilot was not facing an easy task. She had to drop packages at specific points scattered in a dangerous area. Furthermore, the pilot could only fly over the area once in a straight line, and she had to fly over as many points as possible. All points were given by means of integer coordinates in a two-dimensional space. The pilot wanted to know the largest number of points from the given set that all lie on one line. Can you write a program that calculates this number?
Your program has to be efficient!
Input
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
The input consists of N pairs of integers, where 1 < N < 700. Each pair of integers is separated by one blank and ended by a new-line character. The list of pairs is ended with an end-of-file character. No pair will occur twice.
Output
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
The output consists of one integer representing the largest number of points that all lie on one line.
Sample Input
11 12 23 39 1010 11
Sample Output
3
#include <iostream>#include <cstdio>#include<cstring>#include <cmath>using namespace std;int x[10005],y[10005];int cnt;int tmp,Max;void found() { Max=1; int i,j,k; for(i=0;i<cnt;i++) for(j=i+1;j<cnt;j++) { tmp=2; for(k=j+1;k<cnt;k++) { if((y[j]-y[i])*(x[k]-x[j])==(y[k]-y[j])*(x[j]-x[i])) tmp++; } Max=max(Max,tmp); } printf("%d\n",Max); }int main(){ int T; char str[110]; scanf("%d%*c",&T); getchar(); while(T--) { cnt=0; memset(x,0,sizeof(x)); memset(y,0,sizeof(y)); while(gets(str)) { if(!str[0]&&cnt) break; sscanf(str,"%d%d",&x[cnt],&y[cnt]); cnt++; } found(); if(T) printf("\n"); } return 0;}
- UVa 270 - Lining Up
- UVa 270 - Lining Up
- uva 270 - Lining Up
- UVa 270 - Lining Up
- UVa 270 - Lining Up
- UVA 270 - Lining Up
- UVA 270 Lining Up
- uva 270 Lining Up
- uva 270 Lining Up
- Lining up(uva 270)
- UVa 270 - Lining Up
- uva 270 - Lining Up
- uva 270 Lining Up
- UVA 270 - Lining Up
- UVA - 270 Lining Up
- Lining Up - UVa 270
- uva 270 Lining Up
- UVA 270 Lining Up
- 易语言注册多个热键源码
- 2013 ACM-ICPC杭州赛区全国邀请赛——题目重现
- JNI学习积累之一 ---- 常用函数大全
- 天津网络赛---数论分析题)
- hdu 4584水题
- UVA 270 Lining Up
- 高次同余方程式的解数及解法
- 周渝民默认与喻虹渊恋情 七夕不送女友礼物
- POJ2154(Pólya定理与欧拉函数优化)
- 理想的技术面试过程
- 闪回删除例子
- hdu 4585 shaolin (暴力)
- 连分数
- 自定义 GridView 分页代码