标签:
Time Limit: 20 Sec
Memory Limit: 256 MB
http://codeforces.com/gym/100187/problem/H
Everyone probably heard the rumours about the constellation of Bermuda Triangle: any person who looks to this constellation of three stars is said to disappear completely. Though, it‘s not clear who then spreads these rumours.
Recently two photos have been sent to the editorial office of the newspaper you work on. Each photo depicts three glowing points on the dark background. The note applied to the photos indicates that they are the photos of the constellation of the Bermuda Triangle.
Of course, the editors cannot check if it‘s true without the risk of the stuff. But at least it is possible to make sure that each photo depicts the same triple of stars. Remember that photos could be taken with the different zoom and rotation. They could also be taken with the help of a mirror in order to decrease the risk of triggering the curse.
As a regular programmer of the newspaper you have the task to determine if these photos can depict the same triple of stars.
Input
The input consists of 6 lines. Each of the first three lines contains two integers separated by space — the coordinates of stars on the first photo. Each of the next three lines also contains two integers — the coordinates of stars on the second photo. All coordinates are between - 104 and 104, inclusively. Stars on each photo don‘t coincide and don‘t lie on the same line.
Output
Output «YES» if the photos can depict the same triple of stars and «NO» otherwise.
Sample Input
0 0
0 2
1 0
0 0
0 4
2 0
Sample Output
YES
题意
给你俩三角形,问你是否相似
题解:
就问你是否相似……
代码
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <sstream> #include <queue> #include <typeinfo> #include <fstream> #include <map> #include <stack> typedef long long ll; using namespace std; //freopen("D.in","r",stdin); //freopen("D.out","w",stdout); #define sspeed ios_base::sync_with_stdio(0);cin.tie(0) #define test freopen("test.txt","r",stdin) #define maxn 2001001 #define mod 1000000009 #define eps 1e-9 const int inf=0x3f3f3f3f; const ll infll = 0x3f3f3f3f3f3f3f3fLL; inline ll read() { ll x=0,f=1;char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } //************************************************************************************** struct node { double x,y; }; double dis(node a,node b) { return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y); } node a[3]; node b[3]; int main() { for(int i=0;i<3;i++) cin>>a[i].x>>a[i].y; for(int i=0;i<3;i++) cin>>b[i].x>>b[i].y; double aa[10]; double bb[10]; int step=0; for(int i=0;i<3;i++) for(int j=i+1;j<3;j++) aa[step++]=dis(a[i],a[j]); step=0; for(int i=0;i<3;i++) for(int j=i+1;j<3;j++) bb[step++]=dis(b[i],b[j]); sort(aa,aa+3); sort(bb,bb+3); int flag=0; if(aa[0]/bb[0]==aa[1]/bb[1]&&aa[1]/bb[1]==aa[2]/bb[2]) flag=1; if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; }
codeforces Gym 100187H H. Mysterious Photos 水题
标签:
原文地址:http://www.cnblogs.com/qscqesze/p/4657714.html