結果

問題 No.1243 約数加算
ユーザー gr1msl3ygr1msl3y
提出日時 2022-05-17 22:11:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 76,876 KB
最終ジャッジ日時 2023-10-13 23:59:51
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,336 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 77 ms
71,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def count(a, b):
    return b.bit_length()-a.bit_length()


def solve(A, B):
    res = []
    n = count(A, B)
    v = B >> n
    for i in range(A.bit_length()):
        if (A >> i) & 1 and not (v >> i) & 1:
            res.append(1 << i)
            A += 1 << i
    n = count(A, B)
    v = B >> n
    for i in range(A.bit_length()-1, -1, -1):
        if ((A ^ v) >> i) & 1:
            res.append(1 << i)
            A += 1 << i
    for i in range(n-1, -1, -1):
        res.append(A)
        A <<= 1
        if (B >> i) & 1:
            res.append(1)
            A += 1
    return res


T = int(input())
ans = []
for _ in range(T):
    A, B = map(int, input().split())
    ans.append(solve(A, B))

for a in ans:
    print(len(a))
    print(*a)
0