結果

問題 No.1243 約数加算
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-03 16:30:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 78,652 KB
最終ジャッジ日時 2023-09-25 05:22:31
合計ジャッジ時間 2,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,484 KB
testcase_01 AC 92 ms
71,848 KB
testcase_02 AC 91 ms
71,736 KB
testcase_03 AC 90 ms
71,596 KB
testcase_04 AC 109 ms
77,808 KB
testcase_05 AC 113 ms
77,608 KB
testcase_06 AC 112 ms
77,600 KB
testcase_07 AC 122 ms
78,652 KB
testcase_08 AC 114 ms
77,772 KB
testcase_09 AC 93 ms
71,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
from collections import deque
import math
for _ in range(t):
    a,b = map(int,input().split())
    l = []
    r = []
    for i in range(120):
        if a == b:
            break
        g = math.gcd(a, b)
        if (a//g)%2 == 1:
            l.append(g)
            a += g
        if (b//g)%2 == 1:
            r.append(g)
            b -= g
    r.reverse()
    ans = l+r
    print(len(ans))
    print(*ans)
0