codeforces Gym 100187H H. Mysterious Photos 水题

H. Mysterious Photos

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100187/problem/H

Description

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

HINT

题意

给你俩三角形,问你是否相似

题解:

就问你是否相似……

代码

#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;

}
时间: 2024-12-24 12:13:20

codeforces Gym 100187H H. Mysterious Photos 水题的相关文章

codeforces 707A A. Brain&#39;s Photos(水题)

题目链接: A. Brain's Photos 题意: 问是黑白还是彩色; 思路: 没有思路: AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include <map> u

【Codeforces 368A】Brain&#39;s Photos 水题

黑白灰都是#Black&White #include <cstdio> int n,m; int main() { scanf("%d%d",&n,&m); int ok=0; for(int i=0;i<n;i++) for(int j=0;j<m;j++) { char s[5]; scanf("%s",s); if(s[0]!='W'&&s[0]!='B'&&s[0]!='G')

CodeForces 707A Brain&#39;s Photos (水题)

题意:给一张照片的像素,让你来确定是黑白的还是彩色的. 析:很简单么,如果有一种颜色不是黑白灰,那么就一定是彩色的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #i

CodeForces 690C1 Brain Network (easy) (水题,判断树)

题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h> using namespace std; const int maxn =1000 + 5; int p[maxn]; int Find(int x){ return x == p[x] ? x : p[x] = Find(p[x]); } int main(){ int n, m, x, y; cin

Codeforces Gym 100114 H. Milestones 离线树状数组

H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description The longest road of the Fairy Kingdom has n milestones. A long-established tradition defines a specific color for milestones in each region, with a

CodeForces 342B Xenia and Spies (水题模拟,贪心)

题意:给定 n 个间谍,m个区间,一个 s,一个f,然后从 s开始传纸条,然后传到 f,然后在每个 t 时间在区间内的不能传,问你最少的时间传过去. 析:这个题,就模拟一下就好,贪心策略,能传就传,找好方向,一直传就行,传到 f 就结束. 代码如下: #include <bits/stdc++.h> using namespace std; struct node{ int l, r, t; bool operator < (const node &p) const{ retur

CodeForces 342A Xenia and Divisors (水题)

题意:给定 n 个数(小于等于7),让你把它分成 m 组,每组有三个数,且满足,a < b < c,并且 a 能整除 b,b 能整除 c. 析:对于这个题,因为题目说了是不大于7的,那么一想不就三组数么,124,136,126.就这三组,然后确定每一组的数量,首先只有第二组有3,那么第二组的数量就确定了, 然后再看剩下的两组,只有第一组有4,那么第一组也就确定,然后剩下的就是第三组,当然第三组只有6. 代码如下: #include <bits/stdc++.h> using nam

CodeForces 686A Free Ice Cream (水题模拟)

题意:给定初始数量的冰激凌,然后n个操作,如果是“+”,那么数量就会增加,如果是“-”,如果现有的数量大于等于要减的数量,那么就减掉,如果小于, 那么孩子就会离家.问你最后剩下多少冰激凌,和出走的孩子数量. 析:多水的一个题,就是一个模拟,如果是+,就加上,如果是‘-’,就判断一下,如果不够,就记录下来. 代码如下: #include <iostream> #include <cmath> #include <cstdlib> #include <set>

Codeforces Gym 100463B Music Mess Hash 逻辑题

Music Mess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Description Francis really likes his music. He especially likes that song ’Zombie Nation’. Or was that the album? Or maybe the album was ’Kernkraft 4