結果
問題 | No.1871 divisXor |
ユーザー |
|
提出日時 | 2022-03-11 22:49:35 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 445 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 82,644 KB |
実行使用メモリ | 53,852 KB |
最終ジャッジ日時 | 2024-09-22 12:59:42 |
合計ジャッジ時間 | 3,800 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
N = int(input()) import sys if N == 0: print(-1) exit() if N == 1: print(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)