This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
vector<ll> powMOD(n+1);
powMOD[0] = 1;
for (int i = 1; i <= n; i++) {
powMOD[i] = (powMOD[i-1] * 2) % MOD;
}
k--;
for (int i = 0; i < n; i++) {
add--;
if (k % 2 == 1) {
pos += powMOD[add];
}
k /= 2;
}
cout << pos << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |