結果

問題 No.1200 お菓子配り-3
コンテスト
ユーザー LyricalMaestro
提出日時 2026-07-04 01:09:27
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 870 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 837 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,792 KB
最終ジャッジ日時 2026-07-04 01:09:39
合計ジャッジ時間 10,944 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/1200

import math

def solve(X, Y):
    z = X + Y
    sqrt_z = int(math.sqrt(z))

    divisors = []
    for r in range(2, sqrt_z +1):
        if z % r == 0:
            q = z // r
            divisors.append(r)
            if q != divisors:
                divisors.append(q)
    
    answer = 0
    for d in divisors:
        a = d - 1
        z0 = z // d
        if a > 1:
            if (X - z0) > 0 and (X - z0) % (a - 1) == 0:
                b = (X - z0) // (a - 1)
                c = z0 - b
                if c > 0:
                    answer += 1
    return answer


def main():
    S = int(input())
    answers = []
    for _ in range(S):
        X, Y = map(int, input().split())
        ans = solve(X, Y)
        answers.append(ans)
    
    for ans in answers:
        print(ans)




if __name__ == "__main__":
    main()
0