結果

問題 No.1200 お菓子配り-3
ユーザー 👑 tatyamtatyam
提出日時 2020-07-19 22:54:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,855 ms / 4,000 ms
コード長 609 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 77,040 KB
最終ジャッジ日時 2024-04-30 23:40:44
合計ジャッジ時間 20,112 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,016 KB
testcase_01 AC 35 ms
58,896 KB
testcase_02 AC 36 ms
57,976 KB
testcase_03 AC 36 ms
58,568 KB
testcase_04 AC 37 ms
57,952 KB
testcase_05 AC 38 ms
58,108 KB
testcase_06 AC 38 ms
58,652 KB
testcase_07 AC 63 ms
61,652 KB
testcase_08 AC 57 ms
61,588 KB
testcase_09 AC 57 ms
61,936 KB
testcase_10 AC 55 ms
61,344 KB
testcase_11 AC 55 ms
62,204 KB
testcase_12 AC 188 ms
73,608 KB
testcase_13 AC 191 ms
74,500 KB
testcase_14 AC 191 ms
74,268 KB
testcase_15 AC 194 ms
74,052 KB
testcase_16 AC 185 ms
73,560 KB
testcase_17 AC 508 ms
76,764 KB
testcase_18 AC 715 ms
76,676 KB
testcase_19 AC 211 ms
74,380 KB
testcase_20 AC 1,290 ms
76,768 KB
testcase_21 AC 1,307 ms
76,772 KB
testcase_22 AC 1,522 ms
77,040 KB
testcase_23 AC 1,325 ms
76,668 KB
testcase_24 AC 1,261 ms
76,484 KB
testcase_25 AC 1,310 ms
76,980 KB
testcase_26 AC 1,302 ms
76,752 KB
testcase_27 AC 35 ms
52,080 KB
testcase_28 AC 1,048 ms
76,652 KB
testcase_29 AC 2,855 ms
77,008 KB
testcase_30 AC 2,756 ms
77,000 KB
testcase_31 AC 35 ms
52,720 KB
testcase_32 AC 33 ms
53,264 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 <= 10_000)
for _ in range(s):
    x, y = map(int, input().split())
    assert(1 <= x <= 500_000_000)
    assert(1 <= y <= 500_000_000)
    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