Problem 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

题意:给出n个点的坐标,求最多能确定多少个互不平行的直线。

思路:用atan()函数求出所有点的斜率,排序后进行判断即可。

Source Program

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<vector>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define N 1050
#define MOD 123
#define E 1e-6
using namespace std;
struct Point{double x;double y;
}point[N];
double a[N*N];
double Calculate(Point p1, Point p2)
{Point p;p.x=p2.x-p1.x;p.y=p2.y-p1.y;if(fabs(p.x)<E)//斜率不存在return 1;double temp=atan(p.y/p.x);if(temp<0)//注意斜率的范围return 1+temp;elsereturn temp;
}int main()
{int n;scanf("%d",&n);for(int i=0;i<n;i++)scanf("%lf%lf",&point[i].x,&point[i].y);int k=0;for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){a[k]=Calculate(point[i],point[j]);k++;}sort(a,a+k);int ans=1;for(int i=1;i<k;i++)if(a[i]!=a[i-1])ans++;printf("%d\n",ans);return 0;
}

Game of Lines(POJ-3668)相关推荐

  1. Silver Cow Party (POJ - 3268 )

    Silver Cow Party (POJ - 3268 ) 这道题是我做的最短路专题里的一道题,但我还没做这个,结果比赛就出了,真是.......... 题目: One cow from each ...

  2. Bailian2734 十进制到八进制【入门】(POJ NOI0113-45)

    问题链接:POJ NOI0113-45十进制到八进制 2734:十进制到八进制 总时间限制: 1000ms 内存限制: 65536kB 描述 把一个十进制正整数转化成八进制. 输入 一行,仅含一个十进 ...

  3. Bailian2676 整数的个数【入门】(POJ NOI0105-11)

    问题链接:POJ NOI0105-11 整数的个数 2676:整数的个数 总时间限制: 1000ms 内存限制: 65536kB 描述 给定k(1 < k < 100)个正整数,其中每个数 ...

  4. Bailian4029 数字反转【进制】(POJ NOI0105-29)

    问题链接:POJ NOI0105-29 数字反转 4029:数字反转 总时间限制: 1000ms 内存限制: 65535kB 描述 给定一个整数,请将该数各个位上数字反转得到一个新数.新数也应满足整数 ...

  5. Bailian2735 八进制到十进制【入门】(POJ NOI0113-46)

    问题链接:POJ NOI0113-46 八进制到十进制 2735:八进制到十进制 总时间限制: 1000ms 内存限制: 65536kB 描述 把一个八进制正整数转化成十进制. 输入 一行,仅含一个八 ...

  6. 吴昊品游戏核心算法 Round 7 —— 熄灯游戏AI(有人性的Brute Force)(POJ 2811)

    暴力分为两种,一种属于毫无人性的暴力,一种属于有人性 的暴力.前面一种就不说了,对于后面一种情况,我们可以只对其中的部分问题进行枚举,而通过这些子问题而推导到整个的问题中.我称之为有人性的Brute ...

  7. 【二分】Best Cow Fences(poj 2018)

    Best Cow Fences poj 2018 题目大意: 给出一个正整数数列,要你求平均数最大,长度不小于M的字串,结果乘1000取整 输入样例 10 6 6 4 2 10 3 8 5 9 4 1 ...

  8. 主席树学习小结(POJ 2104)

    在高中的时候就听到过主席树了,感觉非常高端,在寒假的时候 winter homework中有一题是查找区间第K大的树,当时就开始百度这种网上的博客,发现主席树看不懂,因为那个root[i],还有tx[ ...

  9. A - TOYS(POJ - 2318) 计算几何的一道基础题

    Calculate the number of toys that land in each bin of a partitioned toy box. 计算每一个玩具箱里面玩具的数量 Mom and ...

  10. 昂贵的聘礼(poj 1062)

    Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家拿不出这么多金币,便请求酋长降低 ...

最新文章

  1. 《微信公众平台应用开发实战(第2版)》一导读
  2. java filter 返回错误消息_java filter 导致错误310
  3. JavaScript初步入门
  4. this.counter$ = store.select(fromExample.getCounterCounter);
  5. 被问到有没有内核开发经验_一个人就是一个开发团队!成电硬核毕业生自制迷你电脑走红!...
  6. 通过mod_limitipconn模块来限制apache的并发连接数
  7. 【转】DCMTK各模块说明!!!!!!!
  8. 转载C#中的特性(Attributes)
  9. Pytorch环境安装【Python3.7+Anaconda3+CUDA10.1】
  10. php中的字符串可以当做数组调用
  11. 2021新版OPEN易支付免费开源版 亲测可用
  12. jquery timepicker
  13. k8s-v1.2.3部署mysql-8服务
  14. CentOS 7 下安装五笔输入法
  15. 软文广告的写作技巧分析!
  16. 回收站清空数据恢复步骤如何
  17. 幼儿园教学方案植树节
  18. 2022年ccpc威海站
  19. java字符串反转reverse();
  20. highcharts 设置渐变色

热门文章

  1. 百度吹过的牛实现了,你的呢?5本书带你搞定AI前沿技术
  2. 干掉项目中杂乱的 if-else,试试状态模式,这才是优雅的实现方式!
  3. 推荐几个来自北大、南开的大神的公众号!
  4. 硬核干货,老曹解密“语音交互”背后的黑科技!
  5. 张一鸣:优秀年轻人的五个特点
  6. 微信开发本地调试工具(模拟微信客户端)
  7. 【图像去模糊】 deconvolution总结
  8. Linux常用命令(第二版) --系统开关机命令
  9. Hadoop--Yarn常用命令 与 生产环境核心配置参数
  10. How to Simulate the Price Order or Price Line Function using API QP_PREQ_PUB.PRICE_REQUEST Includes