# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
288458 | Benmath | Rack (eJOI19_rack) | C++14 | 1 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
컴파일 시 표준 에러 (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... |