結果
問題 | No.2881 Mod 2^N |
ユーザー |
![]() |
提出日時 | 2024-09-20 01:33:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 959 bytes |
コンパイル時間 | 2,205 ms |
コンパイル使用メモリ | 200,584 KB |
最終ジャッジ日時 | 2025-02-24 09:40:48 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp:6:12: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 6 | bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; } | ^~~~ main.cpp:6:21: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 6 | bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; } | ^~~~ main.cpp:7:12: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 7 | bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; } | ^~~~ main.cpp:7:21: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 7 | bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; } | ^~~~
ソースコード
#include<bits/stdc++.h> #define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++) #define all(v) begin(v),end(v) using namespace std; using ll = long long; bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; } bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; } int main(){ cin.tie(0)->sync_with_stdio(0); ll n,x,y; cin >> n >> x >> y; if (x==y){ cout << 0 << '\n'; return 0; } if ((y&1) == 0) { cout << -1 << '\n'; return 0; } deque<ll> bits(n); rep(i,0,n){ bits[n-1-i] = (y>>i&1); } while(bits.front() == 0) { bits.pop_front(); } bits.pop_front(); vector<ll> ls; while(!bits.empty()){ int cnt = 0; while(bits.front() == 0) { cnt++; bits.pop_front(); } cnt++; bits.pop_front(); ls.push_back(cnt); } vector<ll> a; a.push_back(n); rep(i,0,(int)ls.size()){ a.push_back(ls[i]); } cout << (int)a.size() << '\n'; rep(i,0,(int)a.size()){ cout << a[i] << ' '; } cout << '\n'; }