Submission #440420

# Submission time Handle Problem Language Result Execution time Memory
440420 2021-07-02T09:03:32 Z stoyan_malinin Rack (eJOI19_rack) C++14
0 / 100
1000 ms 204 KB
#include <iostream>

using namespace std;

long long n, k;

long long getNum(long long pos, int p2, long long seqPos)
{
    while(seqPos+(1LL<<(n-1-p2))<=pos)
    {
        seqPos += (1LL<<(n-1-p2));
        p2++;
    }
    if(pos==seqPos) return (1LL<<(p2-1));

    long long nextSeqPos = seqPos+(1LL<<(n-1-p2));
    long long diff = pos - seqPos;

    return getNum(nextSeqPos+diff, p2, seqPos) - (1LL<<p2);
}

int main()
{
    cin >> n >> k;
    cout << getNum(k, 0, 1) << '\n';
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -