Submission #407224

#TimeUsernameProblemLanguageResultExecution timeMemory
407224luka1234Rack (eJOI19_rack)C++14
100 / 100
6 ms204 KiB
#include <bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; ll p=1000000007; ll logpow(ll v,ll e){ if(e==0) return 1; else{ if(e%2==0){ ll ans=logpow(v,e/2); ans%=p; ans=ans*ans; ans%=p; return ans; } else{ ll ans=logpow(v,e/2); ans%=p; ans=ans*ans; ans%=p; ans*=v; ans%=p; return ans; } } } int main(){ ll n,m; cin>>n>>m; ll v=1,cnt=0; while(cnt!=n){ if(m%2==1) v=2*v; else v=2*v+1; v%=p; if(m%2==0) m=m/2; else m=m/2+1; cnt++; } ll pow=logpow(2,n)-1; pow%=p; ll ans=v-pow; if(ans<0) ans=p-abs(ans); cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...