Submission #232150

# Submission time Handle Problem Language Result Execution time Memory
232150 2020-05-16T09:35:53 Z Dremix10 Rack (eJOI19_rack) C++17
100 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


ll expo(ll x, ll n, ll m){
    if(n==0)return 1;
    ll u=expo(x,n/2,m);
    u=(u*u)%m;
    if(n%2)u=(u*x)%m;
    return u;
}


int main (){
long long n,k;
cin>>n>>k;
n--;
long long start;

if(n>59)
    start=1;
else{
    ll temp=1e18;
    ll res=expo(2,n,temp);
    if(k<=res)
        start=1;
    else{
        start=2;
        k-=res;
    }
}
//cout<<start<<endl;

int mod=1e9+7;

while(k>(ll)1){

    if(k%2){
        k/=2;
        k++;
    }
    else{
        k/=2;
        start+=expo(2,n,mod);
        start%=mod;
    }
    n--;

}

cout<<start<<endl;

}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Correct 5 ms 372 KB Output is correct