CF1551A Polycarp and Coins
题目描述
Polycarp 需要精确地支付 $n$ 元。他有两种面额的硬币:一种是 $1$ 元,一种是 $2$ 元。Polycarp 对于希望所支付的两种硬币数量差尽可能小。
您需要帮助 Polycarp 确定两个非负整数数 $c_1$ 和 $c_2$,分别对应 $1$ 元硬币和 $2$ 元硬币的数量。所以应当满足 $c_1 + 2 \cdot c_2 = n$ 且 $|c_1 - c_2|$最小。
输入格式
第一行输入一个正整数 $t(1 \le t \le 10^4)$ ——测试点的数量。然后是 $t$ 组测试点。
每组测试点占一行,包括一个正整数 $n(1 \le n \le 10^9)$ ——Polycarp 所需要支付的钱。
输出格式
对于每一个测试点,只输出一行,包括用空格分开的两个整数 $c_1$ 和 $c_2$,若有多解,任意输出一个即可。
说明/提示
The answer for the first test case is "334 333". The sum of the nominal values of all coins is $ 334 \cdot 1 + 333 \cdot 2 = 1000 $ , whereas $ |334 - 333| = 1 $ . One can't get the better value because if $ |c_1 - c_2| = 0 $ , then $ c_1 = c_2 $ and $ c_1 \cdot 1 + c_1 \cdot 2 = 1000 $ , but then the value of $ c_1 $ isn't an integer.
The answer for the second test case is "10 10". The sum of the nominal values is $ 10 \cdot 1 + 10 \cdot 2 = 30 $ and $ |10 - 10| = 0 $ , whereas there's no number having an absolute value less than $ 0 $ .