Polycarp and Coins solution codeforces

Polycarp and Coins solution codeforces


Solution

Coming Soon


.

Polycarp must pay exactly nn burles at the checkout. e 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 c1c1 and c2c2 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+2c2=nc1+2⋅c2=n), and the absolute value of the difference between c1c1 and c2c2 is as little as possible (i. e. you must minimize |c1c2||c1−c2|).

Input Polycarp and Coins solution codeforces

The first line contains one integer tt (1t1041≤t≤104) — the number of test cases. Then tt test cases follow.

Each test case consists of one line. This line contains one integer nn (1n1091≤n≤109) — the number of burles to be paid by Polycarp.

Output Polycarp and Coins solution codeforces

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

input Polycarp and Coins solution codeforces

Copy
6
1000
30
1
32
1000000000
5

output

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

The answer for the first test case is “334 333“. The sum of the nominal values of all coins is 3341+3332=1000334⋅1+333⋅2=1000, whereas |334333|=1|334−333|=1. One can’t get the better value because if |c1c2|=0|c1−c2|=0, then c1=c2c1=c2 and c11+c12=1000c1⋅1+c1⋅2=1000, but then the value of c1c1 isn’t an integer.

The answer for the second test case is “10 10“. The sum of the nominal values is 101+102=3010⋅1+10⋅2=30 and |1010|=0|10−10|=0, whereas there’s no number having an absolute value less than 00.

 

Solution

Coming Soon


What a Reversal solution codeforcesPolycarp and Coins solution codeforces

Leave a Comment