#include <iostream> #include <algorithm> #include <cmath> #include <string.h> #include <vector> using namespace std; const int mod = 998244353; #define ll long long ll quick_mi(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans = ans * a; a = a * a; b >>= 1; } return ans; } int n, m; ll ju(ll x, ll tm) { ll ans = 0; int w = 0; while (x != 0) { if ((tm >> 1) < x) { x -= (tm >> 1) + 1; ans = (1 << w) + ans; } else { ans = (0 << w) + ans; } tm = tm >> 1; w++; } return ans; } void solve() { cin >> n >> m; ll tmp = quick_mi(2, n) - 1; ll x; while (m--) { cin >> x; cout << ju(x, tmp) << endl; } } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T = 1; // cin >> T; while (T--) solve(); return 0; }
}
全部评论
(2) 回帖