欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1998A.Find K Distinct Points with Fixed Center
Find K Distinct Points with Fixed Center
I couldn't think of a good title for this problem, so I decided to learn from LeetCode.— Sun Tzu, The Art of War
You are given three integers , , and (, ).
You need to find distinct points (), (), , (), having integer coordinates, on the 2D coordinate plane such that:
- their center is ()
- for all from to
It can be proven that at least one set of distinct points always exists that satisfies these conditions.
The center of points (), (), , () is $\left( \frac{x_1 + x_2 + \ldots + x_k}{k}, \frac{y_1 + y_2 + \ldots + y_k}{k} \right)$.
Input
The first line contains () — the number of test cases.
Each test case contains three integers , , and (, ) — the coordinates of the center and the number of distinct points you must output.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output lines, the -th line containing two space separated integers, and , () — denoting the position of the -th point.
If there are multiple answers, print any of them. It can be shown that a solution always exists under the given constraints.
Note
For the first test case, $\left( \frac{10}{1}, \frac{10}{1} \right) = (10, 10)$.
For the second test case, $\left( \frac{-1 + 5 - 4}{3}, \frac{-1 -1 + 2}{3} \right) = (0, 0)$.
Samples
4
10 10 1
0 0 3
-5 -8 8
4 -5 3
10 10
-1 -1
5 -1
-4 2
-6 -7
-5 -7
-4 -7
-4 -8
-4 -9
-5 -9
-6 -9
-6 -8
1000 -1000
-996 995
8 -10
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |