Submission #260076

#TimeUsernameProblemLanguageResultExecution timeMemory
260076mosiashvililukaRack (eJOI19_rack)C++14
100 / 100
36 ms30840 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,k,mod=1000000007LL,ka; long long xar(long long q, long long w){ if(w==0) return 1LL; long long qw=xar(q,w/2); if(w%2==0) return (qw*qw); else return ((qw*qw)*q); } long long rec(long long q, long long w){ if(q==1){ return w; } if(q-1>=ka||xar(2,q-1)>=w){ return (rec(q-1,w)*2-1+mod)%mod; }else{ return (rec(q-1,w-xar(2,q-1))*2)%mod; } } int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a>>k; for(ka=1; ; ka++){ if(xar(2,ka)>=k) break; } cout<<rec(a,k); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...