問題一覧 > 通常問題

No.1200 Sweets Distribution-3

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 80
作問者 : PCTprobability / テスター : tatyam
お気に入りにしたユーザー ProblemId : 4755 / 自分の提出
問題文最終更新日: 2020-08-29 17:25:39
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 263 (順位表) の他の問題:

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