85. Three Points On A Line

时间限制1000 ms    内存限制 65536 KB    

题目描述

Given points on a 2D plane, judge whether there're three points that locate on the same line.

输入格式

The number of test cases T(1≤T≤10)  appears in the first line of input.

Each test case begins with the number of points N(1≤N≤100) . The following N  lines describe the coordinates (x i ,y i )  of each point, in accuracy of at most 3 decimals. Coordinates are ranged in [−10 4 ,10 4 ] .

输出格式

For each test case, output Yes if there're three points located on the same line, otherwise outputNo.

输入样例

2
3
0.0 0.0
1.0 1.0
2.0 2.0
3
0.001 -2.000
3.333 4.444
1.010 2.528

输出样例

Yes
No

三点共线,枚举所有的3点,求斜率,一样则存在,做好标记然后退出枚举即可。还有一种做法是求出一组后,把计算结果存起来,减少计算量。

#include<stdio.h>
int main(){int t,n,i,j,k;double x[105],y[105];for(scanf("%d",&t);t--;){scanf("%d",&n);for(i=0;i<n;i++)scanf("%lf%lf",x+i,y+i);int sig=0;for(i=0;i<n&&!sig;i++)for(j=i+1;j<n&&!sig;j++){for(k=j+1;k<n&&!sig;k++){if((y[k]-y[i])/(x[k]-x[i])==(y[j]-y[i])/(x[j]-x[i]))sig=1;}}if(sig)printf("Yes\n");else printf("No\n");}return 0;
}

北邮OJ 85. Three Points On A Line相关推荐

  1. 北邮oj题库刷题计划(更新ing)

    北邮oj题库刷题计划(更新ing) 83. A + B Problem 84 Single Number 85. Three Points On A Line 120 日期 121 最值问题 122 ...

  2. 北邮OJ 141 虚数

    北邮OJ 虚数 #include <bits/stdc++.h> using namespace std; typedef struct fushu{int x; //实部 int y; ...

  3. 校外如何登陆北邮oj

    由于北邮oj不对外开放,准备复试的我需要进入北邮oj:其他小朋友也有这个想法.故写此博客. 先找北邮土著借北邮账号,包括一些认识的同学,直系学长学姐,他们都很乐意帮助的~ 下面是校外进北邮校内网的方法 ...

  4. 北邮OJ 2016 网预-Square Coins

    时间限制 1000 ms 内存限制 65536 KB 题目描述 Artoria, also known as Saber-chan, was born into a time of chaos and ...

  5. 北邮OJ 2016网预 - Saber's Conjecture

    时间限制 1000 ms 内存限制 65536 KB 题目描述 In a parallel universe, young Saber-chan does not have a humongous a ...

  6. 北邮OJ 1027. 16校赛-Archer in Archery

    时间限制 1000 ms 内存限制 65536 KB 题目描述 Archer(Emiya), also known as the red A, is famous for his talented s ...

  7. 北邮OJ 1022. 16校赛-Saber's Board

    时间限制 5000 ms 内存限制 65536 KB 题目描述 In a parallel universe, Saber has won the champion of every kind of ...

  8. 北邮OJ 1021. 16校赛-Stone Game

    时间限制 4000 ms 内存限制 65536 KB 题目描述 Alice and Bob are old friends in game theory. This afternoon they me ...

  9. 北邮OJ 1010. 16校赛-Binary Strings

    时间限制 5000 ms 内存限制 65536 KB 题目描述 One day, the teacher asked Weishen to judge whether a binary string ...

最新文章

  1. python3.8自带matlop和numpy吗_Python enlop包_程序模块 - PyPI - Python中文网
  2. UNIX下C语言的图形编程-curses.h函数库
  3. webapi 返回类型
  4. 给求职的同学的几点建议
  5. .NET不用代码生成器自己写一个生成Code的DLL 自动动态生成三层架构(一)概况...
  6. 【kruskal重构树】【主席树】werewolf 狼人(P4899)
  7. MySQL获取连接_MySQL 连接查询超全详解
  8. oracle 更改分区列,ORA-14061: 不能更改索引分区列的数据类型或长度
  9. 使用宏破解EXCEL工作表保护密码的方法
  10. linux中UDP编程
  11. 法兰克焊接机器人编程入门_FANUC机器人应用
  12. Tapestry介绍
  13. 生态版图 | 10月份YashanDB获信创产品认证,并与3款产品完成互认证
  14. 让女人无法抗拒的30句表白
  15. 等额本金和等额本息两种贷款方式的比较
  16. 虚拟机上linux挂载u盘,linux虚拟机上挂载U盘
  17. 2021卫辉高考成绩查询,卫辉中考成绩查询2021
  18. 关于用python爬虫白嫖漫画这档子事
  19. win8 桌面显示计算机图标怎么删除,win8系统桌面图标显示快捷方式箭头怎么删除...
  20. win7安装linux主题,[老友win10系统]Window7+CentOS6.5双系统安装图文教程

热门文章

  1. 面向中文短文本的实体链指任务竞赛亚军DeepBlueAI团队技术分享
  2. 算法竞赛入门与进阶 (四)二分
  3. html页面右侧滚动,HTML5页面点击和左右滑动页面滚动
  4. jquery无法删除一级域名cookie
  5. JavaScript——易班优课YOOC课群在线测试禁止右键和复制解决方案
  6. Spring Boot + IntelliJ IDEA——自动部署[Spring Boot热部署]+LiveReload[前端自动刷新、热加载]解决方案
  7. Apache——启动错误:[Cannot load modules/mod_actions.so into server]解决方案
  8. bearBaby loves sleeping
  9. Bear and Raspberry
  10. linux按时间升序排列文件,Linux展示以时间生升序显示文件