結果
問題 | No.2881 Mod 2^N |
ユーザー |
![]() |
提出日時 | 2024-11-06 11:19:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 606 bytes |
コンパイル時間 | 2,037 ms |
コンパイル使用メモリ | 196,308 KB |
最終ジャッジ日時 | 2025-02-25 02:25:26 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; long long x, y; cin >> n >> x >> y; if (x == y) { cout << "0\n\n"; return 0; } if (y % 2 == 0) { cout << "-1\n"; return 0; } vector<int> ans(1, n); vector<int> sigs; for (int i = n - 1; i >= 0; i--) { if ((y >> i) & 1) { sigs.push_back(i); } } for (int i = 0; i < (int)sigs.size() - 1; i++) { ans.push_back(sigs[i] - sigs[i + 1]); } cout << ans.size() << '\n'; for (int i : ans) { cout << i << ' '; } cout << endl; }