POJ 2606 Rabbit hunt【简单几何】
来源:互联网 发布:淘宝直通车有用吗 编辑:程序博客网 时间:2024/05/18 06:53
Rabbit hunt
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8015 Accepted: 3993
Description
A good hunter kills two rabbits with one shot. Of course, it can be easily done since for any two points we can always draw a line containing the both. But killing three or more rabbits in one shot is much more difficult task. To be the best hunter in the world one should be able to kill the maximal possible number of rabbits. Assume that rabbit is a point on the plane with integer x and y coordinates. Having a set of rabbits you are to find the largest number K of rabbits that can be killed with single shot, i.e. maximum number of points lying exactly on the same line. No two rabbits sit at one point.
Input
An input contains an integer N (2<=N<=200) specifying the number of rabbits. Each of the next N lines in the input contains the x coordinate and the y coordinate (in this order) separated by a space (-1000<=x,y<=1000).
Output
The output contains the maximal number K of rabbits situated in one line.
Sample Input
67 1228 1399 15610 17311 190-100 1
Sample Output
5
Source
Ural State University collegiate programming contest 2000
原题链接:http://poj.org/problem?id=2606
这题和上一篇博客的那个题目差不多,就输入有点不同。
AC代码;
#include <iostream>#include <cstdio>using namespace std;struct Point{ int x,y;}a[705];int main(){ int n; //freopen("data/2606.txt","r",stdin); while(cin>>n) { for(int i=0;i<n;i++) scanf("%d%d",&a[i].x,&a[i].y); //cin>>a[i].x>>a[i].y; int maxx=2; for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { int ans=2; for(int k=j+1;k<n;k++) { if((a[j].x-a[i].x)*(a[k].y-a[j].y)==(a[j].y-a[i].y)*(a[k].x-a[j].x)) ans++; if(ans>maxx) maxx=ans; } } } cout<<maxx<<endl; } return 0;}
0 0
- POJ 2606 Rabbit hunt【简单几何】
- POJ 2606 Rabbit hunt(计算几何)
- poj 2606 Rabbit hunt
- poj 2606 Rabbit hunt
- 【POJ 2606】Rabbit hunt
- POJ 2606 Rabbit hunt
- POJ 2606 / URAL 1502 Rabbit hunt (计算几何)
- POJ 2606 Rabbit hunt 笔记
- poj 2606 Rabbit hunt 解题报告
- poj Rabbit hunt
- poj P2606 Rabbit hunt
- POJ 1118 Lining Up & POJ 2606 Rabbit hunt(模拟)
- poj 2606 Rabbit hunt【同一条直线上的点】
- poj 1118 Lining Up || poj 2780 Linearity || poj 2606 Rabbit hunt
- URAL 1849|Rabbit Hunt 2|计算几何|二分|Set
- POJ 2606 Rabbit hunt(我的水题之路——斜率最多)
- poj 1066 Treasure Hunt 计算几何计数
- POJ 1066 Treasure Hunt --几何,线段相交
- ReseverLink
- easyui中如何禁用tab选项卡的f5以及enter建
- Flask Web 开发 邮件功能
- express web开发框架安装
- HTML 转 PDF 支持中文
- POJ 2606 Rabbit hunt【简单几何】
- 北京地铁R1线
- Android 不重复启动APP
- iTunes connect开发指南
- Java中synchronized,sleep()和wait()的初略认知
- 读取角色的血值
- 安卓控件背景的简单绘制
- 复习(数据结构):树:C语言
- Android学习笔记-IPC机制浅析