結果

問題 No.1243 約数加算
ユーザー HAPPAHAPPA
提出日時 2020-10-03 18:42:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 7,952 KB
最終ジャッジ日時 2023-09-25 05:34:36
合計ジャッジ時間 1,178 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,888 KB
testcase_01 AC 16 ms
7,812 KB
testcase_02 AC 16 ms
7,916 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 19 ms
7,824 KB
testcase_05 AC 22 ms
7,848 KB
testcase_06 AC 23 ms
7,860 KB
testcase_07 AC 20 ms
7,920 KB
testcase_08 AC 23 ms
7,952 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    t = int(input())
    for _ in range(t):
        a, b = map(int, input().split())

        target = 0
        for i in reversed(range(60)):
            if not(a & (1 << i)) and b & (1 << i):
                target = i
                break

        cnt = 0
        res1 = []
        for i in range(60):
            if a & (1 << target):
                break
            elif a & (1 << i):
                cnt += 1
                res1.append(1 << i)
                a += (1 << i)
        res2 = []
        for i in range(60):
            if not (a & (1 << i)) and (b & (1 << i)):
                cnt += 1
                a += (1 << i)
                res2.append(1 << i)
        res = res1 + res2[::-1]
        print(cnt)
        print(*res)


if __name__ == '__main__':
    resolve()
0