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>
#define endl "\n"
#define int long long
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
const int N = 1e6 + 10;
const int MOD = 1e9 + 7;
int bp (int n) {
if (!n) return 1;
if (n & 1) return 2ll * bp(n-1) % MOD;
int b = bp(n>>1);
return b * b % MOD;
}
int n, k, ans = 1;
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
k --;
for (int i = n - 1; i >= 0; -- i)
if (k & 1) {
ans += bp(i);
ans %= MOD;
k >>= 1;
}
else k >>= 1;
cout << ans << endl;
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... |