#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>
#define MOD 1000000007
#define endl '\n'
typedef long long ll;
void print(vi v){
cout<<"Contents of vector:\n";
for(auto x : v) cout<<x<<" ";
cout<<endl<<endl;
}
void solve(){
ll n, k; cin>>n>>k;
int l = 1, r = min((long long)pow(2, n), LLONG_MAX);
while(true){
if(r - l == 0) break;
int mid = (r+l) / 2;
//cout<<"l: "<<l<<" r: "<<r<<" mid: "<<mid<<endl;
if(k%2){
r = mid;
} else {
l = mid;
}
k = ceil(k*1.0 / 2.0);
}
cout<<r+1%MOD<<endl;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
//ifstream cin("input.txt"); ofstream cout("output.txt");///cia failai
//int T; cin>>T;
int T = 1;
for(int it = 1; it<=T; it++){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |