欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1612A.Distance
Distance
Let's denote the Manhattan distance between two points (with coordinates ) and (with coordinates ) as . For example, the distance between two points with coordinates and is .
You are given two points, and . The point has coordinates , the point has coordinates .
Your goal is to find a point such that:
- both coordinates of are non-negative integers;
- (without any rounding);
- (without any rounding).
Find any point that meets these constraints, or report that no such point exists.
Input
The first line contains one integer () — the number of test cases.
Each test case consists of one line containing two integers and () — the coordinates of the point .
Output
For each test case, print the answer on a separate line as follows:
- if it is impossible to find a point meeting the constraints, print "
-1 -1" (without quotes); - otherwise, print two non-negative integers not exceeding — the coordinates of point meeting the constraints. If there are multiple answers, print any of them. It can be shown that if any such point exists, it's possible to find a point with coordinates not exceeding that meets the constraints.
Note
Explanations for some of the test cases from the example:
- In the first test case, the point has coordinates . If the point has coordinates , then the distance from to is , the distance from to is , and the distance from to is .
- In the second test case, the point has coordinates . If the point has coordinates , then the distance from to is , the distance from to is , and the distance from to is .
- In the third and the fourth test cases, it can be shown that no point with integer coordinates meets the constraints.
- In the fifth test case, the point has coordinates . If the point has coordinates , then the distance from to is , the distance from to is , and the distance from to is .
Samples
10
49 3
2 50
13 0
0 41
42 0
0 36
13 37
42 16
42 13
0 0
23 3
1 25
-1 -1
-1 -1
21 0
0 18
13 12
25 4
-1 -1
0 0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |