結果

問題 No.1200 お菓子配り-3
ユーザー 👑 tatyamtatyam
提出日時 2020-07-19 22:55:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,042 ms / 4,000 ms
コード長 604 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 77,356 KB
最終ジャッジ日時 2024-04-30 23:42:22
合計ジャッジ時間 22,485 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,676 KB
testcase_01 AC 41 ms
58,952 KB
testcase_02 AC 42 ms
58,976 KB
testcase_03 AC 43 ms
58,276 KB
testcase_04 AC 43 ms
58,248 KB
testcase_05 AC 43 ms
58,936 KB
testcase_06 AC 42 ms
58,228 KB
testcase_07 AC 65 ms
62,280 KB
testcase_08 AC 63 ms
60,836 KB
testcase_09 AC 64 ms
61,844 KB
testcase_10 AC 64 ms
61,848 KB
testcase_11 AC 62 ms
62,072 KB
testcase_12 AC 212 ms
74,616 KB
testcase_13 AC 215 ms
74,744 KB
testcase_14 AC 214 ms
74,480 KB
testcase_15 AC 217 ms
74,844 KB
testcase_16 AC 217 ms
74,128 KB
testcase_17 AC 578 ms
77,356 KB
testcase_18 AC 794 ms
76,480 KB
testcase_19 AC 241 ms
73,800 KB
testcase_20 AC 1,455 ms
76,904 KB
testcase_21 AC 1,475 ms
76,824 KB
testcase_22 AC 1,693 ms
77,092 KB
testcase_23 AC 1,455 ms
77,032 KB
testcase_24 AC 1,439 ms
76,740 KB
testcase_25 AC 1,440 ms
76,936 KB
testcase_26 AC 1,446 ms
76,876 KB
testcase_27 AC 38 ms
53,280 KB
testcase_28 AC 1,153 ms
76,724 KB
testcase_29 AC 3,038 ms
77,288 KB
testcase_30 AC 3,042 ms
77,000 KB
testcase_31 AC 38 ms
52,628 KB
testcase_32 AC 37 ms
53,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisor(x):
    ans = []
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            ans.append(i)
            if i * i != x:
                ans.append(x / i)
    return ans

s = int(input())
assert(1 <= s <= 10000)
for _ in range(s):
    x, y = map(int, input().split())
    assert(1 <= x <= 500000000)
    assert(1 <= y <= 500000000)
    if x == y:
        print(len(divisor(x)) + x + x % 2 - 3)
        continue
    ans = 0
    if x < y:
        x, y = y, x
    n = x - y
    for d in divisor(n):
        a = n // d + 1
        ans += y > d and not (y - d) % (a + 1)
    print(ans)
0