Submission #675726

#TimeUsernameProblemLanguageResultExecution timeMemory
675726AlmaRack (eJOI19_rack)C++17
40 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll MOD = 1e9+7; int main() { ios::sync_with_stdio(false); cin.tie(NULL); ll n, k; cin >> n >> k; ll pos = 1, add = n; bool inv = false; vector<int> powMOD(n+1); powMOD[0] = 1; for (int i = 1; i <= n; i++) { powMOD[i] = (powMOD[i-1] * 2) % MOD; } int i = 0; while (i < n) { if ((1 << i) > k) { inv = true; break; } add--; if (inv == false) { if ((k & (1 << i))) { inv = true; } else { pos += powMOD[add]; pos %= MOD; } } else { if ((k & (1 << i))) { pos += powMOD[add]; pos %= MOD; } } i++; } while (i < n) { add--; if (inv == false) { pos += powMOD[add]; pos %= MOD; } i++; } cout << pos << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...