結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
👑 tatyam
|
| 提出日時 | 2020-07-19 22:55:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,989 ms / 4,000 ms |
| コード長 | 604 bytes |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 77,168 KB |
| 最終ジャッジ日時 | 2024-11-20 22:24:16 |
| 合計ジャッジ時間 | 21,923 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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 <= 10000)
for _ in range(s):
x, y = map(int, input().split())
assert(1 <= x <= 500000000)
assert(1 <= y <= 500000000)
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)
tatyam