結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
👑 ![]() |
提出日時 | 2020-07-19 22:54:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,895 ms / 4,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 243 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 77,084 KB |
最終ジャッジ日時 | 2024-11-20 22:22:37 |
合計ジャッジ時間 | 21,327 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
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)