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;
int mod = 1e9 + 7;
int main() {
int n;
ll k;
cin >> n >> k;
if(k == 1) {
cout << 1 << '\n';
return 0;
}
ll S = 0;
int m = 0;
while((1LL << m) < k) {
m++;
}
while(k > 1) {
S += (1LL << (n - m));
S %= mod;
k -= (1LL << (m - 1));
while((1LL << (m - 1)) >= k) {
m--;
}
}
if(k == 1) {
S++;
S %= mod;
}
cout << S << '\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... |