結果

問題 No.1200 お菓子配り-3
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-10-01 17:01:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 656 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 81,632 KB
最終ジャッジ日時 2023-09-21 06:59:06
合計ジャッジ時間 42,221 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,180 KB
testcase_01 AC 77 ms
75,448 KB
testcase_02 AC 82 ms
75,436 KB
testcase_03 AC 81 ms
75,364 KB
testcase_04 AC 80 ms
75,288 KB
testcase_05 AC 81 ms
75,184 KB
testcase_06 AC 78 ms
75,536 KB
testcase_07 AC 120 ms
76,152 KB
testcase_08 AC 121 ms
76,100 KB
testcase_09 AC 126 ms
76,232 KB
testcase_10 AC 121 ms
76,252 KB
testcase_11 AC 119 ms
76,120 KB
testcase_12 AC 486 ms
77,548 KB
testcase_13 AC 494 ms
77,524 KB
testcase_14 AC 498 ms
77,848 KB
testcase_15 AC 500 ms
77,684 KB
testcase_16 AC 490 ms
78,012 KB
testcase_17 AC 1,476 ms
77,760 KB
testcase_18 AC 2,057 ms
78,140 KB
testcase_19 AC 566 ms
77,628 KB
testcase_20 AC 3,825 ms
77,796 KB
testcase_21 AC 3,843 ms
78,016 KB
testcase_22 TLE -
testcase_23 AC 3,825 ms
77,536 KB
testcase_24 AC 3,789 ms
77,632 KB
testcase_25 AC 3,828 ms
77,784 KB
testcase_26 AC 3,800 ms
77,880 KB
testcase_27 AC 72 ms
71,316 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0