No.1200 Sweets Distribution-3
タグ : / 解いたユーザー数 80
作問者 :
PCTprobability
/ テスター :
tatyam
Problem Statement
Since the intended solution takes about $1400$ ms, the time limit has been changed to $4000$ ms.
There are $X$ chocolates and $Y$ cookies here. When $B$ chocolates each were given to $A$ children, $C$ chocolates were left over, and when $C$ cookies each were given to them, $B$ cookies were left over. Note that they did not necessarily give out as many as possible. Given positive integers $X,Y$, find how many such triples of positive integers $A,B,C$ exist.
Answer $S$ test cases per $1$ input. 21:48 The problem statement was corrected. 21:51 The problem statement was corrected. 8/29 17:25 A rejudge was performed due to the TL change.
Input
First, the number of test cases $S$ is given.$S$
Below this, $S$ test cases follow over $S$ lines. Each test case is given in the following format.
$X\ \ Y$
- All inputs are integers.
- $1 \le S \le 10^4$
- $1 \le X,Y \le 5×10^8$
Output
For each test case, output the answer. Print a newline at the end.
Sample
Sample 1
Input
1 23 13
Output
3
The triples satisfying the conditions are the 3 triples $(A,B,C)=(2,11,1),(11,2,1),(3,7,2)$.
Sample 2
Input
5 34 45 467 234 8753 4321 123 7654 875432 86557
Output
0 0 0 0 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。