# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288458 | Benmath | 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;
int main(){
int n;
cin>>n;
long long int k;
cin>>k;
long int step[n+1];
long long int mod=10e8+7;
step[0]=1;
for(int i=1;i<=n;i++){
step[i]=(step[i-1]*2)%mod;
}
if(k==1){
cout<<1;
}else{
if(k==2){
cout<<step[n-1]+1;
}else{
long long int y;
if(k%2==0){
y=(k-2)/2;
}else{
y=(k-1)/2;
}
long long int ti;
long long int li;
long long int step1=1;
long long int mi=0;
for(int i=1;i<=n;i++){
if(i!=1){
step1=step1*2;
mi++;
}
if((y-step1)<step1){
ti=step1;
li=y-step1;
break;
}
}
long long int a1=step[n-2-mi] ;
li=li%mod;
long long int b=(2*li+1)%mod;
long long int res=(a1*b+1)%mod;
if(k%2==0){
res=(res+step[n-1])%mod;
}
cout<<res;
}
}
}
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... |