結果

問題 No.1871 divisXor
ユーザー ああいいああいい
提出日時 2022-03-11 22:45:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 71,616 KB
最終ジャッジ日時 2023-10-14 08:01:57
合計ジャッジ時間 6,720 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,536 KB
testcase_01 AC 72 ms
71,308 KB
testcase_02 AC 85 ms
71,168 KB
testcase_03 AC 75 ms
71,468 KB
testcase_04 AC 73 ms
71,244 KB
testcase_05 AC 73 ms
71,268 KB
testcase_06 AC 74 ms
71,520 KB
testcase_07 AC 71 ms
71,556 KB
testcase_08 AC 73 ms
71,360 KB
testcase_09 AC 74 ms
71,352 KB
testcase_10 AC 74 ms
71,372 KB
testcase_11 AC 73 ms
71,416 KB
testcase_12 AC 73 ms
71,444 KB
testcase_13 AC 72 ms
71,084 KB
testcase_14 AC 73 ms
71,268 KB
testcase_15 AC 73 ms
71,616 KB
testcase_16 AC 71 ms
71,272 KB
testcase_17 AC 72 ms
71,236 KB
testcase_18 AC 73 ms
71,404 KB
testcase_19 AC 71 ms
71,372 KB
testcase_20 AC 74 ms
71,272 KB
testcase_21 AC 73 ms
71,404 KB
testcase_22 WA -
testcase_23 AC 80 ms
71,560 KB
testcase_24 AC 83 ms
71,424 KB
testcase_25 AC 81 ms
71,276 KB
testcase_26 AC 79 ms
71,548 KB
testcase_27 AC 81 ms
71,272 KB
testcase_28 AC 79 ms
71,116 KB
testcase_29 AC 82 ms
71,116 KB
testcase_30 AC 79 ms
71,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

import sys
if N == 0:
    print(-1)
    exit()
if N == 1:
    print(1)
    exit()

ans = []
k = N.bit_length()
ans.append(1 << (k-1))
now = (1 << k) - 1
for i in range(k-1,-1,-1):
    mask = 1 << i
    if now & mask and N & mask == 0:
        ans.append(mask)
        now ^= (1 << (i+1))-1
    elif now & mask == 0 and N & mask:
        ans.append(mask)
        now ^= (1 << (i+1)) - 1
print(len(ans))
print(*ans)
0