Submission #467884

# Submission time Handle Problem Language Result Execution time Memory
467884 2021-08-25T12:19:49 Z alontanay Rack (eJOI19_rack) C++14
40 / 100
5 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll square(ll n) {
    return n*n;
}

ll pow2(ll n) {
    if(n == 0) { return 1; }
    return ((n%2)+1)*square(pow2(n/2));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;
    ll curr_pow = 1, total = 0;
    for( ; n >= 60; n --) {
        curr_pow = (curr_pow*2)%MOD;
    }
    for(ll i = pow2(n)/2; i > 0; i >>= 1) {
        if(i < k) {
            total = (total + curr_pow)%MOD;
            k -= i;
        }
        curr_pow = (curr_pow*2)%MOD;
    }
    cout << (total+1)%MOD << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 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 0 ms 204 KB Output is correct
3 Correct 0 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 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 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 0 ms 204 KB Output is correct
3 Correct 0 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 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 Incorrect 5 ms 204 KB Output isn't correct