結果
問題 | No.1871 divisXor |
ユーザー |
👑 ![]() |
提出日時 | 2022-03-11 21:35:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 974 ms |
コンパイル使用メモリ | 77,776 KB |
最終ジャッジ日時 | 2025-01-28 08:17:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <atcoder/modint> using namespace std; using i64 = long long; using m32 = atcoder::static_modint<998244353>; #define rep(i,n) for(int i=0; i<(int)(n); i++) int main(){ i64 N; cin >> N; if(N == 0){ cout << "-1\n"; return 0; } vector<i64> ans; for(int d=39; d>=0; d--){ i64 divsum = ((i64)1 << d) * 2 - 1; if((N ^ divsum) < N){ N ^= divsum; ans.push_back((i64)1 << d); } } cout << ans.size() << '\n'; rep(i,ans.size()){ if(i) cout << " "; cout << ans[i]; } cout << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;