結果
問題 | No.1871 divisXor |
ユーザー |
![]() |
提出日時 | 2022-03-11 22:04:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 431 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 71,244 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 12:57:47 |
合計ジャッジ時間 | 3,129 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
#include <iostream> #include <vector> using namespace std; typedef long long ll; int main() { ll n; cin >> n; if(n == 0){ cout << -1 << endl; return 0; } vector<ll> ans; for(int i = 50; i >= 0; i--){ if((n >> i) & 1){ ans.push_back(1ll << i); n ^= (1ll << (i + 1)) - 1; } } cout << ans.size() << endl; for(ll x : ans) cout << x << " "; cout << endl; }