【练习】数论

E. Draw a triangle

https://codeforces.com/gym/104008/problem/E

time limit per test: 1 second

memory limit per test: 512 megabytes

input: standard input

output: standard output

Little Desprado2 is a student of Springfield Flowers Kindergarten. On this day, he had just learned how to draw triangles on grid coordinate paper. However, he soon found it very dull, so he came up with a more interesting question:

He had drawn two integral points of the triangle on the grid paper, and he denotes them ( x 1 , y 1 ) (x_1,y_1) (x1,y1) and ( x 2 , y 2 ) (x_2,y_2) (x2,y2). Now, he wanted to know the answer to the following question: where can he draw the third point ( x 3 , y 3 ) (x_3,y_3) (x3,y3) so that the area of the triangle is positive but minimized?

Obviously, he can’t solve this problem because he is too young and simple. Can you tell him the answer?

Please note that your answer’s coordinates must consist of integers because he is drawing on grid paper, and the triangle shouldn’t be a degenerated triangle to keep the area positive.

Input

The first line contains one integer T T T ( 1 ≤ T ≤ 50   000 1\le T\le 50\,000 1T50000), denoting the number of Little Desprado2’s queries.

For each test case, there’s a single line contains four integers x 1 ,   y 1 ,   x 2 ,   y 2 x_1,\ y_1,\ x_2,\ y_2 x1, y1, x2, y2 ( − 1 0 9 ≤ x 1 ,   y 1 ,   x 2 ,   y 2 ≤ 1 0 9 -10^9 \le x_1,\ y_1,\ x_2,\ y_2\le 10^9 109x1, y1, x2, y2109) seperated by spaces, denoting two points are at ( x 1 , y 1 ) (x_1,y_1) (x1,y1) and ( x 2 , y 2 ) (x_2,y_2) (x2,y2), respectively.

It is guaranteed that the two points won’t coincide.
Output

For each test case, print two integers x 3 ,   y 3 x_3,\ y_3 x3, y3 ( − 1 0 18 ≤ x 3 ,   y 3 ≤ 1 0 18 -10^{18}\le x_3,\ y_3\le 10^{18} 1018x3, y31018) in a separated line, denoting your answer.

If there are multiple answers, you can print any one of them. It is guaranteed that there exists a solution in the above range.

计算几何+数论

https://blog.youkuaiyun.com/qq_35866893/article/details/127651969

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值