結果

問題 No.1200 お菓子配り-3
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-28 22:54:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 880 bytes
コンパイル時間 619 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2024-04-27 00:17:18
合計ジャッジ時間 17,126 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 WA -
testcase_03 AC 43 ms
57,728 KB
testcase_04 WA -
testcase_05 AC 43 ms
58,060 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 38 ms
52,352 KB
testcase_28 AC 1,163 ms
76,120 KB
testcase_29 AC 3,034 ms
76,672 KB
testcase_30 AC 3,035 ms
76,672 KB
testcase_31 AC 38 ms
52,096 KB
testcase_32 AC 39 ms
52,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort(reverse=True)
    return divisors

for _ in range(s):
    x, y = map(int, input().split())
    t = x-y
    if t < 0:
        print(0)
    elif t == 0:
        ans = x-1
        D = make_divisors(x)
        if x%2 == 0:
            for d in D:
                if d >= 3:
                    ans += 1
        else:
            for d in D:
                if d >= 2:
                    ans += 1
        print(ans)
    else:
        D = make_divisors(t)
        ans = 0
        for d in D:
            a = d+1
            if (a*y-x)>0 and (a*y-x)%(a**2-1) == 0 and (a*x-y)>0 and (a*x-y)%(a**2-1) == 0:
                 ans += 1
        print(ans)
0