結果
問題 | No.1871 divisXor |
ユーザー |
|
提出日時 | 2022-03-11 22:08:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 887 bytes |
コンパイル時間 | 2,051 ms |
コンパイル使用メモリ | 197,124 KB |
最終ジャッジ日時 | 2025-01-28 08:41:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h>using namespace std;//#include<atcoder/all>//using namespace atcoder;using ll = long long int;using ull = unsigned long long int;using ld = long double;constexpr ll MAX = 2000000000000000000;constexpr ld PI = 3.14159265358979;constexpr ll MOD = 998244353;//2024948111;ld dotorad(ld K){return PI * K / 180.0;}ld radtodo(ld K){return K * 180.0 / PI;}mt19937 mt;void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}int main(){ll N;cin >> N;if(N == 0){cout << -1 << endl;return 0;}vector<ll> ans;ll p = N;for(ll i = 42;i >= 0;i--){if(p & (1LL << i)){p ^= (1LL << (i + 1)) - 1;ans.emplace_back((1LL << (i)));}}cout << (ll)ans.size() << endl;for(ll i = 0;i < (ll)ans.size();i++) cout << ans[i] << " \n"[i == (ll)ans.size() - 1];}