結果

問題 No.1200 お菓子配り-3
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-10-01 17:06:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,034 ms / 4,000 ms
コード長 802 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 82,976 KB
実行使用メモリ 76,708 KB
最終ジャッジ日時 2024-05-01 00:25:48
合計ジャッジ時間 21,379 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
51,824 KB
testcase_01 AC 36 ms
58,896 KB
testcase_02 AC 37 ms
58,256 KB
testcase_03 AC 36 ms
59,584 KB
testcase_04 AC 36 ms
58,064 KB
testcase_05 AC 37 ms
59,464 KB
testcase_06 AC 38 ms
58,920 KB
testcase_07 AC 54 ms
60,204 KB
testcase_08 AC 54 ms
60,228 KB
testcase_09 AC 53 ms
60,316 KB
testcase_10 AC 54 ms
59,692 KB
testcase_11 AC 51 ms
61,236 KB
testcase_12 AC 187 ms
70,856 KB
testcase_13 AC 191 ms
70,176 KB
testcase_14 AC 193 ms
70,268 KB
testcase_15 AC 190 ms
71,204 KB
testcase_16 AC 188 ms
70,388 KB
testcase_17 AC 537 ms
76,508 KB
testcase_18 AC 744 ms
76,180 KB
testcase_19 AC 216 ms
70,648 KB
testcase_20 AC 1,378 ms
76,396 KB
testcase_21 AC 1,388 ms
76,172 KB
testcase_22 AC 1,644 ms
76,708 KB
testcase_23 AC 1,418 ms
76,348 KB
testcase_24 AC 1,391 ms
76,384 KB
testcase_25 AC 1,400 ms
76,480 KB
testcase_26 AC 1,397 ms
76,424 KB
testcase_27 AC 33 ms
51,944 KB
testcase_28 AC 1,088 ms
76,432 KB
testcase_29 AC 3,034 ms
76,188 KB
testcase_30 AC 2,955 ms
76,432 KB
testcase_31 AC 34 ms
53,596 KB
testcase_32 AC 33 ms
52,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def main():
    input = sys.stdin.readline
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]
    Q = int(input())
    for _ in range(Q):
        x, y = map(int, input().split())
        if x == y:
            print(len(make_divisors(x)) + x - 3 + x % 2)
            continue
        ans = 0
        m = abs(x - y)
        mi = min(x, y)
        for i in make_divisors(m):
            n = m // i + 1
            ans += i < mi and not (mi - i) % (n + 1)
        print(ans)
if __name__ == "__main__":
    main()
0