Two students, Adam and Anton, are celebrating two-year anniversary of not passing their Math Logic exam. After very careful search in a local supermarket, they bought a rectangular cake with integer dimensions and two candles.
Later in the campus Adam put the candles into different integer points of the cake and gave a knife toAnton to cut the cake. The cut should start and end at integer points at the edges of the cake, and it should not touch the candles. Also each piece should have exactly one candle at it. Please, help Anton to find the starting and ending points of the cut.
Input
The single line of the input contains six integers: w, h — cake dimensions; ax, ay — x and y coordinates of the first candle; bx, by — the coordinates of the second candle (3 ≤ w,h ≤ 10910^9109;0<ax, bx <w;0<ay,by <h;ax ̸=bx or ay ̸=by).
Output
Output four integers sx, sy, ex, and ey — the starting and ending coordinates of the cut. Both starting and ending point of the cut should belong to the sides of the cake.
If there are several solutions, output any of them.
样例输入复制
7 3 2 2 3 2样例输出复制
0 0 4 3
题目大意:
在一个方格上的交点上放置两个点,两个点不能重叠,不能放置在边上,然后在边上选两个点,使这两点的连线恰好能将之前的两个点分开,而且使之前的两个点任意一个都不能在线上
我们的做法是判断两点是否在一竖列
若不在同一竖列上,就使边上的两个点的横坐标分别为那两个点的横坐标
若在同一点上,就让边上两个点在左右侧的边,并且
#include<iostream>
using namespace std;
int main(){
int m,n;
int ax,ay,bx,by;
cin>>m>>n>>ax>>ay>>bx>>by;
if(ax==bx){
cout<<'0'<<' '<<ay<<' '<<m<<' '<<by<<endl;
}else{
cout<<ax<<' '<<'0'<<' '<<bx<<' '<<n<<endl;
}
}