欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1551A.Polycarp and Coins
Polycarp and Coins
Polycarp must pay exactly burles at the checkout. He has coins of two nominal values: burle and burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other.
Thus, Polycarp wants to minimize the difference between the count of coins of burle and burles being used. Help him by determining two non-negative integer values and which are the number of coins of burle and burles, respectively, so that the total value of that number of coins is exactly (i. e. ), and the absolute value of the difference between and is as little as possible (i. e. you must minimize ).
Input
The first line contains one integer () — the number of test cases. Then test cases follow.
Each test case consists of one line. This line contains one integer () — the number of burles to be paid by Polycarp.
Output
For each test case, output a separate line containing two integers and () separated by a space where is the number of coins of burle and is the number of coins of burles. If there are multiple optimal solutions, print any one.
Note
The answer for the first test case is "334 333". The sum of the nominal values of all coins is , whereas . One can't get the better value because if , then and , but then the value of isn't an integer.
The answer for the second test case is "10 10". The sum of the nominal values is and , whereas there's no number having an absolute value less than .
Samples
6
1000
30
1
32
1000000000
5
334 333
10 10
1 0
10 11
333333334 333333333
1 2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |