結果
問題 | No.1871 divisXor |
ユーザー |
![]() |
提出日時 | 2023-03-11 14:30:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 4,167 ms |
コンパイル使用メモリ | 250,492 KB |
最終ジャッジ日時 | 2025-02-11 09:57:12 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=6000000007999999999; ll mod=1000000007; int main(){ ll n; cin >> n; if (n==0) { cout << -1 << endl; return 0; } ll ok=1; vector<ll>two(60,1); for (ll i = 1; i < 60; i++) { two[i]=two[i-1]*2; } vector<ll>ans; for (ll i = 60; i >=0; i--) { ll z; if (two[i]&n) { z=1; }else{ z=0; } if (z==ok) { ans.push_back(two[i]); ok=1-ok; } } cout << ans.size() << endl; for (ll i = 0; i < ans.size(); i++) { cout << ans[i] << ' '; } cout << endl; }