結果

問題 No.1200 お菓子配り-3
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-10-01 17:03:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 844 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 12,900 KB
最終ジャッジ日時 2023-09-21 06:59:46
合計ジャッジ時間 19,214 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,252 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 44 ms
7,924 KB
testcase_03 AC 43 ms
7,832 KB
testcase_04 AC 44 ms
7,772 KB
testcase_05 AC 52 ms
7,832 KB
testcase_06 AC 42 ms
7,776 KB
testcase_07 AC 244 ms
7,836 KB
testcase_08 AC 255 ms
7,820 KB
testcase_09 AC 243 ms
7,780 KB
testcase_10 AC 238 ms
7,820 KB
testcase_11 AC 236 ms
7,792 KB
testcase_12 AC 2,172 ms
8,236 KB
testcase_13 AC 2,209 ms
8,412 KB
testcase_14 AC 2,212 ms
8,352 KB
testcase_15 AC 2,245 ms
8,400 KB
testcase_16 AC 2,216 ms
8,236 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
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 #

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())
        div = make_divisors(x)
        if x == y:
            print(len(div) + x - 3 + x % 2)
            continue
        ans = 0
        m = abs(x - y)
        div2 = make_divisors(m)
        for i in div2:
            n = m // i + 1
            ans += 1 if i < min(x, y) and (min(x, y) - i) % (n + 1) == 0 else 0
        print(ans)
if __name__ == "__main__":
    main()
0