結果
問題 |
No.1871 divisXor
|
ユーザー |
|
提出日時 | 2022-03-11 22:45:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 432 bytes |
コンパイル時間 | 305 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 51,968 KB |
最終ジャッジ日時 | 2024-09-16 03:10:19 |
合計ジャッジ時間 | 4,171 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 WA * 1 |
ソースコード
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)