結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-01 16:56:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 622 bytes |
| コンパイル時間 | 170 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 77,364 KB |
| 最終ジャッジ日時 | 2024-07-07 01:23:44 |
| 合計ジャッジ時間 | 41,694 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | WA * 25 TLE * 3 -- * 3 |
ソースコード
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:
ans += 1 if i < y and (y - i) % (m // i + 2) == 0 else 0
print(ans)