308638: CF1551A. Polycarp and Coins

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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$,若有多解,任意输出一个即可。

题目描述

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

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. Then $ t $ test cases follow. Each test case consists of one line. This line contains one integer $ n $ ( $ 1 \le n \le 10^9 $ ) — the number of burles to be paid by Polycarp.

输出格式


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

输入输出样例

输入样例 #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 \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 $ .

Input

题意翻译

### 题目描述 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$,若有多解,任意输出一个即可。

加入题单

算法标签: