# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261458 | EJOI2019Andrew | Rack (eJOI19_rack) | C++14 | 1 ms | 256 KiB |
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;
string ans;
map<int,int>freq;
long long int MOD=1000000007;
void rack(long long int k)
{
if(k==1&&freq[k]>1)
return;
if(k%2)
ans+='L';
else
ans+='R';
int fn(0);
if(k%2)
fn=1;
k/=2;
k+=fn;
++freq[k];
rack(k);
}
long long int solve(long long int n)
{
long long int l(1),r(pow(2,n));
for(int i=0; i<ans.length(); ++i)
{
long long int mid=(l+r)/2;
if(ans[i]=='R')
l=mid+1;
else
r=mid-1;
l%=MOD;
r%=MOD;
}
return l;
}
int main()
{
long long int n,k;
cin>>n>>k;
rack(k);
cout<<solve(n);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |