poj 3668 Game of Lines
来源:互联网 发布:澳门电信网络plmn 编辑:程序博客网 时间:2024/05/22 14:54
Farmer John has challenged Bessie to the following game: FJ has a board with dots marked at N (2 ≤ N ≤ 200) distinct lattice points. Dot i has the integer coordinates Xi and Yi (-1,000 ≤ Xi ≤ 1,000; -1,000 ≤ Yi ≤ 1,000).Bessie can score a point in the game by picking two of the dots and drawing a straight line between them; however, she is not allowed to draw a line if she has already drawn another line that is parallel to that line. Bessie would like to know her chances of winning, so she has asked you to help find the maximum score she can obtain.
Input
* Line 1: A single integer: N* Lines 2..N+1: Line i+1 describes lattice point i with two space-separated integers: Xi and Yi.
Output
* Line 1: A single integer representing the maximal number of lines Bessie can draw, no two of which are parallel.
Sample Input
4-1 1-2 00 01 1
Sample Output
4
【题意】
给你很多点,每两个点构成一条直线,问你不平行的直线有多少条。
【分析】
简单暴力
【代码】
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <set>using namespace std;typedef struct{ double x,y;}P;P poi[205];double ans_size[40010];int num=0;int main(){// freopen("in.txt","r",stdin); int t; scanf("%d",&t); for(int i=0;i<t;i++) { scanf("%lf %lf",&poi[i].x,&poi[i].y); for(int j=0;j<i;j++) { if(fabs(poi[i].x-poi[j].x)>1e-6) ans_size[num++]=(poi[i].y-poi[j].y)/(poi[i].x-poi[j].x); else ans_size[num++]=10000000; } } sort(ans_size,ans_size+num); int count = 1; for(int i=1;i<num;i++) { if(fabs(ans_size[i]-ans_size[i-1])>1e-8) count++; } printf("%d\n",count); return 0;}
阅读全文
0 0
- POJ 3668 Game of Lines
- POJ 3668 Game of Lines
- POJ 3668 Game of Lines
- POJ 3668 Game of Lines
- poj 3668 Game of Lines
- POJ 3668 Game of Lines 笔记
- POJ 2668 Game of Lines
- POJ 3668 Game of Lines(n点最多有多少不平行直线)
- 连线游戏Game of Lines
- POJ 3215 Median of Lines 英文少
- POJ 2084 Game of Connections
- poj 2084 Game of Connections
- POJ 2084 Game of Connections
- POJ-2084-Game of Connections
- poj 2084 Game of Connections
- poj 2084 Game of Connections
- [POJ] 2084 -> Game of Connections
- POJ 2084 Game of Connections
- Python eval 函数妙用
- hdu 3506 Monkey Party (区间dp 求环形石子合并+四边形不等式优化)
- Android的权限
- HDU 1828 Picture(线段树的周长并)
- Python爬虫Scrapy框架系列之十四
- poj 3668 Game of Lines
- java将数据写入excel
- 虚拟机 / 虚拟服务器
- break与continue
- C++模板、面向对象内容补充
- 一文弄懂神经网络中的反向传播法——BackPropagation
- python str和repr的区别
- c++中static成员函数、成员变量作用
- block,inline和inline-block概念和区别