Submission #237607

#TimeUsernameProblemLanguageResultExecution timeMemory
237607PbezzRack (eJOI19_rack)C++14
100 / 100
203 ms30840 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define MOD 1000000007 #define MAXN 100005 typedef pair<int, int> pii; ll fast(ll base, ll exp){ if(exp==0) return 1%MOD; ll u = fast(base,exp/2); u=(u*u)%MOD; if (exp%2==1) u=(u*base)%MOD; return u; } ll solve(ll n, ll k){ if(n==1&&k==1)return 1%MOD; if(n==1&&k==2)return 2%MOD; ll ans = fast(2,n-1); if(k%2==0)return (solve(n-1,k/2)+ans)%MOD; else return solve(n-1,(k+1)/2)%MOD; } int main(){ ll n,k,ans; cin>>n>>k; ans=solve(n,k)%MOD; if(ans<0)ans+=MOD; cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...