Submission #440386

# Submission time Handle Problem Language Result Execution time Memory
440386 2021-07-02T08:22:19 Z stoyan_malinin Rack (eJOI19_rack) C++14
100 / 100
1 ms 204 KB
#include <iostream>
#include <vector>
#include <queue>
#include <set>

using namespace std;

const long long mod = 1e9 + 7;

long long fastPow(long long x, long long p)
{
    long long ans = 1, curr = x;

    while(p!=0)
    {
        if(p%2!=0) ans = (ans*curr)%mod;

        p/=2;
        curr = (curr*curr)%mod;
    }

    return ans;
}
long long revBits(long long x, int bitCnt)
{
    long long res = 0;
    for(int bit = 0;bit<min(bitCnt, 63);bit++)
    {
        if(((x>>bit)&1)==1)
            res = (res + fastPow(2, bitCnt-bit-1))%mod;
    }

    return res;
}

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

    cout << (revBits(k-1, n) + 1)%mod << '\n';
}
/*
5 3
5 0 1 2 5
5 2 3
4 2 3
1 4 5

3 1
2 2 1
1 2 3
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct