#P8948. [YsOI2022] NOIp 和省选

[YsOI2022] NOIp 和省选

Background

To check his teaching skills, Ysuperman decided to give two placement tests to kindergarten kids.

Problem Description

One test has four problems, with a total score of 400400; the other test has six problems, with a total score of 600600. For each person, the score in each test is a non-negative integer between 00 and the full score (it can be 00 or the full score).

There are nn students taking these two tests. For student ii, the score of the first test is aia_i, and the score of the second test is bib_i. Ysuperman computes the standard score cic_i using the following rules:

  1. Compute the highest scores of the two tests, A,BA, B, with A0A \ne 0 and B0B \ne 0.
  2. Let ci=1000(aiA+biB)c_i = 1000(\frac{a_i}{A}+\frac{b_i}{B}), where cic_i is rounded to the nearest integer.

After computing every student's standard score, Ysuperman carelessly lost all the original scores. Can you help find any possible set of original scores?

In other words, given nn and the standard scores c1nc_{1\sim n}, you need to find a valid set of a1na_{1\sim n} and b1nb_{1\sim n} satisfying the requirements above.

In particular, there is a very strong kid, Qiu, who got the highest score in both tests, so it is guaranteed that c1=2000c_1 = 2000. Also, the other kids are at a similar level, so it is guaranteed that i>1,ci[10,1990]\forall i>1, c_i \in [10,1990].

Input Format

The first line contains a positive integer nn.

The next nn lines each contain a positive integer cic_i on line ii.

Output Format

Output nn lines. On line ii, output two non-negative integers ai,bia_i, b_i. From the statement, you must ensure ai[0,400]a_i \in [0,400], bi[0,600]b_i \in [0,600], and maxai>0\max a_i > 0, maxbi>0\max b_i > 0.

4
2000
1319
1476
996
233 525
147 361
200 324
0 523
4
2000
1704
1658
1542
400 454
352 374
352 353
320 337

Hint

In Sample 1, the constructed a,ba, b are valid for the following reasons:

The highest scores of the two tests are 233233 and 525525, respectively.

1000×(233÷233+525÷525)=20001000\times (233\div 233 + 525\div 525)=2000.

$1000\times (147\div 233 + 361\div 525) \approx 1318.520\approx 1319$.

$1000\times (200\div 233 + 324\div 525)\approx 1475.512\approx 1476$.

$1000\times (0\div 233 + 523\div 525)\approx 996.190\approx 996$.

For the first 20%20\% of the testdata, it is guaranteed that n20n \le 20.

For another 20%20\% of the testdata, it is guaranteed that cic_i is a multiple of 1010.

For another 20%20\% of the testdata, it is guaranteed that cic_i is a multiple of 55.

For another 20%20\% of the testdata, it is guaranteed that cic_i is a multiple of 22.

For 100%100\% of the testdata, 1n1041 \le n \le 10^4, c1=2000c_1 = 2000, and i>1,ci[10,1990]\forall i>1, c_i \in [10,1990].

Translated by ChatGPT 5