結果

問題 No.1200 お菓子配り-3
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-28 22:57:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,339 ms / 4,000 ms
コード長 1,104 bytes
コンパイル時間 1,071 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 79,212 KB
最終ジャッジ日時 2023-08-13 05:59:16
合計ジャッジ時間 25,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,516 KB
testcase_01 AC 74 ms
75,928 KB
testcase_02 AC 75 ms
75,768 KB
testcase_03 AC 76 ms
75,884 KB
testcase_04 AC 79 ms
75,772 KB
testcase_05 AC 76 ms
75,772 KB
testcase_06 AC 77 ms
75,828 KB
testcase_07 AC 94 ms
76,036 KB
testcase_08 AC 93 ms
76,040 KB
testcase_09 AC 92 ms
75,996 KB
testcase_10 AC 93 ms
76,216 KB
testcase_11 AC 92 ms
76,724 KB
testcase_12 AC 265 ms
78,896 KB
testcase_13 AC 264 ms
78,628 KB
testcase_14 AC 263 ms
78,684 KB
testcase_15 AC 265 ms
78,688 KB
testcase_16 AC 259 ms
78,636 KB
testcase_17 AC 652 ms
78,900 KB
testcase_18 AC 884 ms
79,108 KB
testcase_19 AC 292 ms
78,664 KB
testcase_20 AC 1,577 ms
79,148 KB
testcase_21 AC 1,577 ms
79,180 KB
testcase_22 AC 1,833 ms
79,212 KB
testcase_23 AC 1,577 ms
79,064 KB
testcase_24 AC 1,554 ms
79,184 KB
testcase_25 AC 1,611 ms
79,112 KB
testcase_26 AC 1,569 ms
79,124 KB
testcase_27 AC 72 ms
71,764 KB
testcase_28 AC 1,232 ms
77,900 KB
testcase_29 AC 3,339 ms
78,268 KB
testcase_30 AC 3,308 ms
78,256 KB
testcase_31 AC 72 ms
71,688 KB
testcase_32 AC 73 ms
71,856 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:
        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)
    elif t > 0:
        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)
    else:
        t = (-1)*t
        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