結果
問題 |
No.1243 約数加算
|
ユーザー |
![]() |
提出日時 | 2025-05-14 12:50:08 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,005 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 81,724 KB |
実行使用メモリ | 53,984 KB |
最終ジャッジ日時 | 2025-05-14 12:51:27 |
合計ジャッジ時間 | 4,037 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()