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;
#define ll long long
#define endl '\n'
const ll MOD = 1e9+7;
const ll INF = 1e16;
const int INT_INF = 1e9;
const ll MAX = 1e6+1;
ll pre[MAX + 5];
ll solve(ll cur, ll layer, ll ans){
ans %= MOD;
if(layer == -1){
return ans;
}
if(cur % 2){
return solve((cur + 1)/2, layer-1, ans);
}
return solve((cur + 1)/2, layer-1, ans + pre[layer]);
}
void solve(){
ll a,b;
cin>>a>>b;
cout<<solve(b, a-1, 1);
}
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(NULL);
int t = 1;
pre[0] = 1;
for(int i = 1; i < MAX + 4; i++){
pre[i] = (pre[i-1]*2)%MOD;
}
//cin >> t;
while(t--){
solve();
cout<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |