結果
問題 | No.1243 約数加算 |
ユーザー |
![]() |
提出日時 | 2025-03-26 16:00:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,274 bytes |
コンパイル時間 | 283 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 74,052 KB |
最終ジャッジ日時 | 2025-03-26 16:01:18 |
合計ジャッジ時間 | 5,787 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 TLE * 1 -- * 4 |
ソースコード
import mathdef get_divisors(n):divisors = set()for i in range(1, int(math.isqrt(n)) + 1):if n % i == 0:divisors.add(i)divisors.add(n // i)return sorted(divisors, reverse=True)def solve():import sysinput = sys.stdin.read().split()T = int(input[0])idx = 1for _ in range(T):A = int(input[idx])B = int(input[idx+1])idx +=2path = []current = Bfound = Falsewhile current > A:delta = current - Aif delta > 0 and A % delta == 0:path.append(delta)current = Abreakdivisors = get_divisors(current)chosen = Nonefor d in divisors:if d == current:continueprev = current - dif prev >= A and prev % d == 0:chosen = dbreakif chosen is not None:path.append(chosen)current -= chosenelse:path.append(1)current -= 1path.reverse()print(len(path))print(' '.join(map(str, path)))solve()