codeforces749B

Parallelogram is Back

 CodeForces - 749B 

已知平行四边形的三个顶点,求第四个顶点可能的位置。Input输入有三行,每行包括两个整数x和y ( - 1000 ≤ xi, yi ≤ 1000),代表一个顶点的横纵坐标。Output输出的第一行为一个整数k,代表第四个顶点可能的位置数。
接下来k行,每行两个整数分别代表第四个顶点的横纵坐标。
输出的点的顺序任意.

Sample Input

0 0
0 1
1 0

Sample Output

3
-1 1
1 -1
1 1

Hint样例中有三个可能的顶点,(1,-1)、(-1,1)和(1,1)。

sol:小学奥数啊,容易知道对角线的坐标和是相等的
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0;
    bool f=0;
    char ch=' ';
    while(!isdigit(ch))
    {
        f|=(ch=='-'); ch=getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
    }
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-'); x=-x;
    }
    if(x<10)
    {
        putchar(x+'0');    return;
    }
    write(x/10);
    putchar((x%10)+'0');
    return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('
')
int main()
{
    int x1,y1,x2,y2,x3,y3;
    R(x1); R(y1);
    R(x2); R(y2);
    R(x3); R(y3);
    puts("3");
    W(x2+x3-x1); Wl(y2+y3-y1);
    W(x1+x3-x2); Wl(y1+y3-y2);
    W(x1+x2-x3); Wl(y1+y2-y3);
    return 0;
}
/*
input
0 0
0 1
1 0
output
3
-1 1
1 -1
1 1
*/
View Code
 
原文地址:https://www.cnblogs.com/gaojunonly1/p/10645166.html