結果
問題 | No.2881 Mod 2^N |
ユーザー |
![]() |
提出日時 | 2024-09-08 13:30:34 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,012 bytes |
コンパイル時間 | 4,960 ms |
コンパイル使用メモリ | 309,468 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-08 13:30:41 |
合計ジャッジ時間 | 6,249 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <atcoder/all>#include <bits/stdc++.h>#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)using namespace atcoder;using namespace std;typedef long long ll;int n;ll f(ll x, int i) { return (x * (1LL << i) + 1) % (1LL << n); }void out(vector<int> a) {cout << a.size() << endl;for (auto x : a) {cout << x << ' ';}cout << endl;}int main() {ll x, y;cin >> n >> x >> y;vector<int> ans;if (x == y) {out(ans);return 0;}if (y == 0) {cout << -1 << endl;return 0;}if (y % 2 == 0) {cout << -1 << endl;return 0;}vector<int> bits;rep(i, 0, 61) {if (y & (1LL << i)) {bits.push_back(i);}}x = 1;ans.push_back(n);reverse(bits.begin(), bits.end());rep(i, 0, bits.size() - 1) { ans.push_back(bits[i] - bits[i + 1]); }out(ans);// rep(i, 0, ans.size()) { x = f(x, ans[i]); }// assert(x == y);}