結果

問題 No.1200 お菓子配り-3
ユーザー 👑 tatyamtatyam
提出日時 2020-07-19 22:03:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 609 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-04-26 22:35:20
合計ジャッジ時間 20,498 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
16,384 KB
testcase_01 AC 31 ms
10,624 KB
testcase_02 AC 41 ms
10,880 KB
testcase_03 AC 42 ms
10,624 KB
testcase_04 AC 39 ms
10,752 KB
testcase_05 AC 44 ms
10,752 KB
testcase_06 AC 39 ms
10,752 KB
testcase_07 AC 124 ms
10,880 KB
testcase_08 AC 124 ms
10,752 KB
testcase_09 AC 117 ms
10,624 KB
testcase_10 AC 115 ms
10,752 KB
testcase_11 AC 108 ms
10,880 KB
testcase_12 AC 880 ms
10,880 KB
testcase_13 AC 895 ms
10,624 KB
testcase_14 AC 894 ms
10,880 KB
testcase_15 AC 910 ms
10,880 KB
testcase_16 AC 891 ms
10,752 KB
testcase_17 AC 3,178 ms
10,624 KB
testcase_18 TLE -
testcase_19 AC 1,059 ms
10,624 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

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