日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

北邮OJ 85. Three Points On A Line

發(fā)布時間:2024/9/30 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 北邮OJ 85. Three Points On A Line 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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(1T10)? appears in the first line of input.

Each test case begins with the number of points N(1N100)?. 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。