Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6791   Accepted: 2523

Description

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 0
0 0
1 1

Sample Output

4

Source

 
 

计算每条线的斜率,然后统计不同斜率的个数就可以。

又陷入了一WA就是好几次的窘境啊……

先是RE,反映半天原来是数组开小了,然后各种WA,于是看了评论区,发现要调精度到1e-8

……

 /**/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const double eps=1e-;
const int mxn=;
double x[mxn],y[mxn];
int n;
double k[mxn*];
int cnt;
int main(){
scanf("%d",&n);
int i,j;
for(i=;i<=n;i++)scanf("%lf%lf",&x[i],&y[i]);
for(i=;i<n;i++)
for(j=i+;j<=n;j++){
if(x[i]==x[j])k[++cnt]=1e15;
else k[++cnt]=(double)(y[i]-y[j])/(x[i]-x[j]);
}
sort(k+,k+cnt+);
int ans=;
ans++;//一定可以画至少一条
for(i=;i<cnt;i++){
if(fabs(k[i]-k[i+])>eps)ans++;
}
cout<<ans;
return ;
}

POJ3668 Game of Lines的更多相关文章

  1. extracting lines bases a list using awk

    extracting lines bases a list using awk awk 'NR==FNR{a[$1]=$0; next}($1 in a){print a[$1]"\n&qu ...

  2. Enum:Game of Lines(POJ 3668)

    画直线 题目大意:给定一些点集,要你找两点之间的连线不平行的有多少条 数据量比较少,直接暴力枚举,然后放到set查找即可 #include <iostream> #include < ...

  3. 我的常用mixin 之 lines

    /** * 最多显示 $lineCount 行 * lines * * example: * @include lines; * @include lines(3); */ @mixin lines( ...

  4. uva 1471 defence lines——yhx

    After the last war devastated your country, you - as the king of the land of Ardenia - decided it wa ...

  5. POJ 1269 Intersecting Lines --计算几何

    题意: 二维平面,给两条线段,判断形成的直线是否重合,或是相交于一点,或是不相交. 解法: 简单几何. 重合: 叉积为0,且一条线段的一个端点到另一条直线的距离为0 不相交: 不满足重合的情况下叉积为 ...

  6. POJ 1269 Intersecting Lines【判断直线相交】

    题意:给两条直线,判断相交,重合或者平行 思路:判断重合可以用叉积,平行用斜率,其他情况即为相交. 求交点: 这里也用到叉积的原理.假设交点为p0(x0,y0).则有: (p1-p0)X(p2-p0) ...

  7. [CareerCup] 13.1 Print Last K Lines 打印最后K行

    13.1 Write a method to print the last K lines of an input file using C++. 这道题让我们用C++来打印一个输入文本的最后K行,最 ...

  8. Codeforces 593B Anton and Lines

    LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output st ...

  9. 简单几何(直线位置) POJ 1269 Intersecting Lines

    题目传送门 题意:判断两条直线的位置关系,共线或平行或相交 分析:先判断平行还是共线,最后就是相交.平行用叉积判断向量,共线的话也用叉积判断点,相交求交点 /********************* ...

随机推荐

  1. Linux入门篇(五)——Shell(一)

    这一系列的Linux入门都是本人在<鸟哥的Linux私房菜>的基础上总结的基本内容,主要是记录下自己的学习过程,也方便大家简要的了解 Linux Distribution是Ubuntu而不 ...

  2. tomcat 无论如何都无法创建新的Servers

    1.退出eclipse 2.到[工程目录下 workspace ]/.metadata/.plugins/org.eclipse.core.runtime 3.把org.eclipse.wst.ser ...

  3. Numpy 索引及切片

    1.一维数组的索引及切片 ar = np.arange(20) print(ar) print(ar[4]) print(ar[3:6]) print(ar[:4:2]) #索引到4 按2的步长 pr ...

  4. POJ:3273-Monthly Expense

    Monthly Expense Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 32067 Accepted: 12081 Des ...

  5. Apache 设置二级域名

    开启重写模块 LoadModule rewrite_module modules/mod_rewrite.so 编辑配置 NameVirtualHost *:80 <VirtualHost *: ...

  6. python基础之继承派生、组合、接口和抽象类

    类的继承与派生 经典类和新式类 在python3中,所有类默认继承object,但凡是继承了object类的子类,以及该子类的子类,都称为新式类(在python3中所有的类都是新式类) 没有继承obj ...

  7. 03,Python网络爬虫第一弹《Python网络爬虫相关基础概念》

    爬虫介绍 引入 为什么要学习爬虫,学习爬虫能够为我们以后的发展带来那些好处?其实学习爬虫的原因和为我们以后发展带来的好处都是显而易见的,无论是从实际的应用还是从就业上. 我们都知道,当前我们所处的时代 ...

  8. Android Studio卡在refreshing gradle project的原因和快速解决办法

    Android Studio更新后一直Refreshing的解决办法! 这个问题遇到过很多次,网上也有很多解决办法,但是好像都没有发现refreshing gradle project在做什么. 一般 ...

  9. 栈和队列&前缀,中缀,后缀

    1.堆和栈的区别? (1)栈内存操作系统来分配,堆内存由程序员自己来分配. (2)栈有系统自动分配,只要栈 剩余空间大于所申请空间,系统将为程序提供内存,否则将报异常提示栈溢出. 2.栈(线性表) 仅 ...

  10. Windows系统搭建Mysql Cluster集群

    简单介绍一下MySQL集群涉及的三种节点:     管理节点(也可以称管理服务器)是整个集群环境的核心,类似于集群中起调度作用的枢纽,由它来负责管理其它节点(数据节点和SQL节点)的开启.关闭或重启某 ...