結果

問題 No.1243 約数加算
ユーザー neterukunneterukun
提出日時 2020-10-02 23:26:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 76,896 KB
最終ジャッジ日時 2023-09-24 23:41:23
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,240 KB
testcase_01 AC 74 ms
71,332 KB
testcase_02 AC 72 ms
71,104 KB
testcase_03 AC 74 ms
71,352 KB
testcase_04 AC 96 ms
76,788 KB
testcase_05 AC 98 ms
76,788 KB
testcase_06 AC 97 ms
76,704 KB
testcase_07 AC 98 ms
76,896 KB
testcase_08 AC 96 ms
76,848 KB
testcase_09 AC 74 ms
71,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    a, b = map(int, input().split())
    ans = []
    
    len_b = len(bin(b)) - 2
    len_a = len(bin(a)) - 2
    for i in range(100)[::-1]:
        if a & (1 << i) != b & (1 << i):
            len_b = i + 1
            break

    for i in range(len_b - 1):
        if a & (1 << i):
            a += 1 << i
            ans.append(1 << i)
    for i in range(len_b)[::-1]:
        if a & (1 << i) != b & (1 << i):
            a += (1 << i)
            ans.append(1 << i)
    print(len(ans))
    print(*ans)
0