标签:1.0 oj int 北邮 bupt 样例 points test line
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 (xi,yi) of each point, in accuracy of at most 3 decimals. Coordinates are ranged in [−104,104].
输出格式
For each test case, output Yes
if there're three points located on the same line, otherwise output No
.
输入样例
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
AC代码
#include <stdio.h>
float x[110],y[110];
int main(){
int t,n;
scanf("%d",&t);
while(t--){
int flag = 0;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%f %f",&x[i],&y[i]);
}
for(int i=0;i<n&&!flag;i++){
for(int j=i+1;j<n&&!flag;j++){
for(int k=j+1;k<n&&!flag;k++){
if((y[k]-y[i])/(x[k]-x[i])==(y[j]-y[i])/(x[j]-x[i]))
flag=1;
}
}
}
if(flag){
printf("Yes\n");
}else{
printf("No\n");
}
}
return 0;
}
标签:1.0,oj,int,北邮,bupt,样例,points,test,line 来源: https://blog.csdn.net/stone_fall/article/details/88357770
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。