結果

問題 No.1200 お菓子配り-3
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-28 22:57:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,022 ms / 4,000 ms
コード長 1,104 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 77,888 KB
最終ジャッジ日時 2024-04-30 23:58:13
合計ジャッジ時間 22,694 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,824 KB
testcase_01 AC 41 ms
58,524 KB
testcase_02 AC 43 ms
57,900 KB
testcase_03 AC 42 ms
58,556 KB
testcase_04 AC 41 ms
58,864 KB
testcase_05 AC 44 ms
58,168 KB
testcase_06 AC 40 ms
58,916 KB
testcase_07 AC 58 ms
60,308 KB
testcase_08 AC 58 ms
60,996 KB
testcase_09 AC 58 ms
61,164 KB
testcase_10 AC 57 ms
60,916 KB
testcase_11 AC 60 ms
61,568 KB
testcase_12 AC 219 ms
77,208 KB
testcase_13 AC 218 ms
77,400 KB
testcase_14 AC 221 ms
76,916 KB
testcase_15 AC 226 ms
77,064 KB
testcase_16 AC 223 ms
77,072 KB
testcase_17 AC 592 ms
77,760 KB
testcase_18 AC 810 ms
77,408 KB
testcase_19 AC 253 ms
77,240 KB
testcase_20 AC 1,450 ms
77,168 KB
testcase_21 AC 1,450 ms
77,124 KB
testcase_22 AC 1,697 ms
77,120 KB
testcase_23 AC 1,454 ms
77,212 KB
testcase_24 AC 1,429 ms
77,528 KB
testcase_25 AC 1,443 ms
77,888 KB
testcase_26 AC 1,444 ms
77,188 KB
testcase_27 AC 38 ms
53,620 KB
testcase_28 AC 1,148 ms
76,992 KB
testcase_29 AC 3,022 ms
76,980 KB
testcase_30 AC 3,001 ms
77,228 KB
testcase_31 AC 36 ms
53,744 KB
testcase_32 AC 37 ms
53,132 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