CF1551A.Polycarp and Coins

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp must pay exactly nn burles at the checkout. He has coins of two nominal values: 11 burle and 22 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 11 burle and 22 burles being used. Help him by determining two non-negative integer values c1c_1 and c2c_2 which are the number of coins of 11 burle and 22 burles, respectively, so that the total value of that number of coins is exactly nn (i. e. c1+2⋅c2=nc_1 + 2 \cdot c_2 = n), and the absolute value of the difference between c1c_1 and c2c_2 is as little as possible (i. e. you must minimize ∣c1−c2∣|c_1-c_2|).

波利卡普在结账时必须恰好支付 nn 布尔。他有两种面额的硬币:11 布尔和 22 布尔。波利卡普对这两种硬币同样喜爱,因此他不希望使用其中一种硬币的数量多于另一种。

于是,波利卡普希望最小化所用的 11 布尔硬币数量与 22 布尔硬币数量之间的差值。请帮助他确定两个非负整数 c1c_1 和 c2c_2,分别表示所用的 11 布尔硬币数和 22 布尔硬币数,使得这些硬币的总价值恰好为 nn(即满足 c1+2⋅c2=nc_1 + 2 \cdot c_2 = n),且 c1c_1 与 c2c_2 的差的绝对值尽可能小(即最小化 ∣c1−c2∣|c_1-c_2|)。

输入格式

The first line contains one integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. Then tt test cases follow.

Each test case consists of one line. This line contains one integer nn (1≤n≤1091 \le n \le 10^9) — the number of burles to be paid by Polycarp.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。接下来是 tt 个测试用例。

每个测试用例由一行组成。该行包含一个整数 nn(1≤n≤1091 \le n \le 10^9)—— Polycarp 需要支付的 burles 数量。

输出格式

For each test case, output a separate line containing two integers c1c_1 and c2c_2 (c1,c2≥0c_1, c_2 \ge 0) separated by a space where c1c_1 is the number of coins of 11 burle and c2c_2 is the number of coins of 22 burles. If there are multiple optimal solutions, print any one.

对于每个测试用例,输出一行,包含两个整数 c1c_1 和 c2c_2(c1,c2≥0c_1, c_2 \ge 0),以空格分隔,其中 c1c_1 表示面值为 11 burle 的硬币数量,c2c_2 表示面值为 22 burles 的硬币数量。若存在多个最优解,输出任意一个即可。

输入输出样例

  • 输入#1

    6
    1000
    30
    1
    32
    1000000000
    5

    输出#1

    334 333
    10 10
    1 0
    10 11
    333333334 333333333
    1 2

说明/提示

The answer for the first test case is "334 333". The sum of the nominal values of all coins is 334⋅1+333⋅2=1000334 \cdot 1 + 333 \cdot 2 = 1000, whereas ∣334−333∣=1|334 - 333| = 1. One can't get the better value because if ∣c1−c2∣=0|c_1 - c_2| = 0, then c1=c2c_1 = c_2 and c1⋅1+c1⋅2=1000c_1 \cdot 1 + c_1 \cdot 2 = 1000, but then the value of c1c_1 isn't an integer.

The answer for the second test case is "10 10". The sum of the nominal values is 10⋅1+10⋅2=3010 \cdot 1 + 10 \cdot 2 = 30 and ∣10−10∣=0|10 - 10| = 0, whereas there's no number having an absolute value less than 00.

第一个测试用例的答案是“334 333”。所有硬币面值的总和为 334⋅1+333⋅2=1000334 \cdot 1 + 333 \cdot 2 = 1000,而 ∣334−333∣=1|334 - 333| = 1。无法得到更优的结果,因为若 ∣c1−c2∣=0|c_1 - c_2| = 0,则 c1=c2c_1 = c_2,此时有 c1⋅1+c1⋅2=1000c_1 \cdot 1 + c_1 \cdot 2 = 1000,但该方程解出的 c1c_1 不是整数。

第二个测试用例的答案是“10 10”。面值总和为 10⋅1+10⋅2=3010 \cdot 1 + 10 \cdot 2 = 30,且 ∣10−10∣=0|10 - 10| = 0;而绝对值不可能小于 00。

输入解题思路,AI测评打分。不知道怎么写?

首页