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. MySQL优化总结-查询总条数

    1.COUNT(*)和COUNT(COL) COUNT(*)通常是对主键进行索引扫描,而COUNT(COL)就不一定了,另外前者是统计表中的所有符合的纪录总数,而后者是计算表中所有符合的COL的纪录数 ...

  2. PLC状态机编程第六篇-优化PLC程序生成

    还记得第一篇博客中,我们在状态机中手写上升沿来处理有别于传统的一键启停程序,那个手写的上升沿就是优化手段.stateflow状态机是带事件的,事件本身支持上升沿和下降沿等事件,在这里,如果我们选择用事 ...

  3. PLC状态机编程第三篇-RS信号处理

    我们今天简要介绍RS指令在状态机中怎么处理的.有些设备按下停止按钮后,没有马上停止,而是到原点后才停止,那么这种情况在状态机中如何表示呢?我们以案例说明之,下面是我们的控制描述. 控制描述 小车从左位 ...

  4. Evevt Loop、任务队列、定时器等

    上周五,一个朋友发给我一道面试题,代码如下: console.log(1); setTimeout(console.log(2), 0); Promise.resolve().then(res =&g ...

  5. struts2官方 中文教程 系列五:处理表单

    先贴个本帖的地址,免得其它网站被爬去了struts2教程 官方系列五:处理表单  即 http://www.cnblogs.com/linghaoxinpian/p/6906298.html 下载本章 ...

  6. Javacript实现倒计时

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  7. Windows下使用Nginx+tomcat配置负载均衡

    Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口 ...

  8. android 文件保存

    将数据保存在外部存储器上 /* Checks if external storage is available for read and write */ public boolean isExter ...

  9. Visual Studio Emulator for Android 折腾记

    想用虚拟机调试Android项目,于是想到了MS免费提供的 Visual Studio Emulator for Android,这玩意价格免费量又足,N久之前试用过,速度杠杠的! 安装包很小,不到4 ...

  10. script通过script标签跨域加载数据

    /********************************************************** 说明:跨域请求数据Javascript组件 ------------------ ...