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 __int128_t MOD = 1e9+7;
#define tol(bi) (1LL<<((__int128_t)(bi)))
__int128_t solve(__int128_t n, __int128_t k){
if (n<=70 && k>tol(n-1)){
return ((__int128_t)solve(n-1,k-tol(n-1))*2ll)%MOD;
}
else {
if (k==1){
return 1ll;
}
if (k%2){
return solve(n-1,k/2+1);
}
else {
return ((__int128_t)solve(n-1,k/2)+tol(n-1))%MOD;
}
}
}
int main(){
int n,k;
cin>>n>>k;
long long ans = solve(n,k);
ans%=MOD;
if (ans<0) ans+=MOD;
cout<<ans<<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... |