No.2624 Prediction by Average
タグ : / 解いたユーザー数 89
作問者 : 👑
Problem Statement
In a certain music exam, the score is represented as an integer from $0$ to $100$ points.
Also, after the exam ends, the value obtained by truncating the mean of all test takers' scores at the $4$-th decimal place is disclosed as the average score.
Now, some people took the exam, and the average score was $S$. It is also known that the number of test takers is at most $N$.
Find how many values are possible for the number of test takers.
You are given $T$ test cases; answer each of them.
Constraints
- $1 \leq T \leq 1000$
- $1 \leq N \leq 10^{13}$
- $0 \leq S \leq 100$
- $T, N$ are integers.
- $S$ is given to $3$ decimal places.
Input
The input is given from standard input in the following format. Here, $case_i$ denotes the $i$-th test case.
$T$ $case_1$ $case_2$ $\vdots$ $case_T$
Each case is given in the following format.
$N$ $S$
Output
Print $T$ lines. The $i$-th line should contain the answer to the $i$-th test case.
Sample
Sample 1
Input
4 5 87.500 9 91.111 27 88.889 3141592653589 100.000
Output
2 1 0 3141592653589
For the $1$-st test case, the average score can be $87.500$ when the number of test takers is $2$ or $4$. For example, when the number of test takers is $2$, if the scores of the $2$ test takers are $85$ points and $90$ points, the mean of the scores is $\frac{85+90}{2} = 87.5$, which satisfies the condition.
For the $2$-nd test case, the condition is satisfied only when the number of test takers is $9$.
For the $3$-rd test case, no number of test takers satisfies the condition.
For the $4$-th test case, the condition is satisfied for every number of test takers that is at most $3141592653589$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。