問題一覧 > 通常問題

No.2624 Prediction by Average

レベル : / AI推定難易度 : 1075 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 89
作問者 : 👑 AngrySadEight / テスター : 👑 loop0919 zeta7532
お気に入りにしたユーザー ProblemId : 10489 / 自分の提出
問題文最終更新日: 2024-01-10 03:06:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 417 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。