P8948 [YsOI2022] NOIp and NOI Qualifier.
Background
To check his teaching skills, Ysuperman decided to give two placement tests to kindergarten kids.
Description
One test has four problems, with a total score of $400$; the other test has six problems, with a total score of $600$. For each person, the score in each test is a **non-negative integer** between $0$ and the full score (it can be $0$ or the full score).
There are $n$ students taking these two tests. For student $i$, the score of the first test is $a_i$, and the score of the second test is $b_i$. Ysuperman computes the **standard score** $c_i$ using the following rules:
1. Compute the highest scores of the two tests, $A, B$, with $A \ne 0$ and $B \ne 0$.
2. Let $c_i = 1000(\frac{a_i}{A}+\frac{b_i}{B})$, where $c_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 $n$ and the **standard scores** $c_{1\sim n}$, you need to find a valid set of $a_{1\sim n}$ and $b_{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 $c_1 = 2000$. Also, the other kids are at a similar level, so it is guaranteed that $\forall i>1, c_i \in [10,1990]$.
Input Format
The first line contains a positive integer $n$.
The next $n$ lines each contain a positive integer $c_i$ on line $i$.
Output Format
Output $n$ lines. On line $i$, output two non-negative integers $a_i, b_i$. From the statement, you must ensure $a_i \in [0,400]$, $b_i \in [0,600]$, and $\max a_i > 0$, $\max b_i > 0$.
Explanation/Hint
In Sample 1, the constructed $a, b$ are valid for the following reasons:
The highest scores of the two tests are $233$ and $525$, respectively.
$1000\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\%$ of the testdata, it is guaranteed that $n \le 20$.
For another $20\%$ of the testdata, it is guaranteed that $c_i$ is a multiple of $10$.
For another $20\%$ of the testdata, it is guaranteed that $c_i$ is a multiple of $5$.
For another $20\%$ of the testdata, it is guaranteed that $c_i$ is a multiple of $2$.
For $100\%$ of the testdata, $1 \le n \le 10^4$, $c_1 = 2000$, and $\forall i>1, c_i \in [10,1990]$.
Translated by ChatGPT 5