結果

問題 No.1200 お菓子配り-3
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-10-01 17:01:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 656 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 83,476 KB
最終ジャッジ日時 2024-07-07 01:25:04
合計ジャッジ時間 38,390 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26 TLE * 2 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
Q = int(input())
for _ in range(Q):
    x, y = map(int, input().split())
    div = make_divisors(x)
    if x == y:
        print(len(div) + x - 3 + x % 2)
        continue
    ans = 0
    m = abs(x - y)
    div2 = make_divisors(m)
    for i in div2:
        n = m // i + 1
        ans += 1 if i < min(x, y) and (min(x, y) - i) % (n + 1) == 0 else 0
    print(ans)
0