国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

poj 1118 Lining Up(暴力+數(shù)學(xué))

2019-11-06 06:10:07
字體:
供稿:網(wǎng)友

Lining Up

Time Limit: 2000MS Memory Limit: 32768K
Total Submissions: 22296 Accepted: 7040

Description

"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

Input consist several case,First line of the each case is an integer N ( 1 < N < 700 ),then follow N pairs of integers. Each pair of integers is separated by one blank and ended by a new-line character. The input ended by N=0.

Output

output one integer for each input case ,representing the largest number of points that all lie on one line.

Sample Input

51 12 23 39 1010 110

Sample Output

3
題意:給你一個(gè)數(shù)n,代表在二維空間內(nèi)的n的點(diǎn),找到在一條直線上最多的點(diǎn)能有多少。
在空間內(nèi)的三個(gè)點(diǎn)共線,滿足(y1-y2)/ (x1-x2)==(y3-y4)/ (x3-x4) ,為了防止分母為0,化成(y1-y2)*(x3-x4)== (x1-x2)*(y3-y4)。用三重循環(huán)即可。
#include<cstdio>#include <algorithm>  #include <cstring> #define LL long longusing namespace std;struct Node{	int x,y;}a[705];int main(){	int n;	while(scanf("%d",&n)&&n)	{		for(int i=0;i<n;i++)		   scanf("%d%d",&a[i].x,&a[i].y);		int sum=0;		for(int i=0;i<n-2;i++)		{			for(int j=i+1;j<n-1;j++)			{				int ans=2;				for(int k=j+1;k<n;k++)				{					if((a[i].x-a[j].x)*(a[k].y-a[j].y)==(a[i].y-a[j].y)*(a[k].x-a[j].x))					    ans++;				}				if(ans>sum)				   sum=ans;			}		}		printf("%d/n",sum);	}	return 0;}

上一篇:UVa11988

下一篇:JVM 垃圾回收機(jī)制

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 锦州市| 偃师市| 澎湖县| 金湖县| 莎车县| 罗山县| 江油市| 平凉市| 水富县| 南丹县| 二连浩特市| 保定市| 朔州市| 靖西县| 东丽区| 铁岭市| 新兴县| 自治县| 平罗县| 吴堡县| 廊坊市| 奎屯市| 武城县| 商南县| 绿春县| 华池县| 且末县| 望城县| 涿鹿县| 海晏县| 武汉市| 乡宁县| 文山县| 台南县| 长垣县| 靖远县| 亚东县| 亚东县| 亚东县| 荣成市| 双桥区|