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;
const long long MOD = (long long) 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
long long k;
cin >> n >> k;
k--;
vector<long long> pw(n);
pw[0] = 1;
for (int i = 1; i < n; i++) {
pw[i] = (pw[i - 1] * 2) % MOD;
}
long long ans = 0;
for (int i = n - 1; i >= 0; i--) {
if (k % 2 == 1) {
ans = (ans + pw[i]) % MOD;
}
k /= 2;
}
cout << ans + 1 << '\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... |