Submission #833629

#TimeUsernameProblemLanguageResultExecution timeMemory
833629tolbiRack (eJOI19_rack)C++17
40 / 100
1 ms212 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...