結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
qwewe
|
| 提出日時 | 2025-04-24 12:23:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,005 bytes |
| コンパイル時間 | 207 ms |
| コンパイル使用メモリ | 81,784 KB |
| 実行使用メモリ | 66,820 KB |
| 最終ジャッジ日時 | 2025-04-24 12:25:28 |
| 合計ジャッジ時間 | 3,864 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 TLE * 1 -- * 6 |
ソースコード
def solve():
import sys
input = sys.stdin.read().split()
idx = 0
T = int(input[idx])
idx += 1
for _ in range(T):
A = int(input[idx])
B = int(input[idx+1])
idx +=2
# Check if B - A is a divisor of A
if (B - A) > 0 and A % (B - A) == 0:
print(1)
print(B - A)
continue
reverse_path = []
current = B
while current > A:
max_d_candidate = current - A
d = None
# Find the largest divisor <= max_d_candidate
for candidate in range(max_d_candidate, 0, -1):
if current % candidate == 0:
d = candidate
break
reverse_path.append(d)
current -= d
# Reverse to get the forward path
reverse_path.reverse()
print(len(reverse_path))
print(' '.join(map(str, reverse_path)))
if __name__ == '__main__':
solve()
qwewe