Submission #509713

# Submission time Handle Problem Language Result Execution time Memory
509713 2022-01-14T08:29:12 Z tudor Rack (eJOI19_rack) C++17
100 / 100
6 ms 4044 KB
#include <iostream>
using namespace std;
const int mod = 1e9 + 7;
const int nmax = 1e6;
int p2[nmax + 1];
void precalc ( int n ) {
    p2[0] = 1;
    for ( int i = 1; i <= n; i++ ) {
        p2[i] = p2[i - 1] + p2[i - 1];
        if ( p2[i] >= mod )
            p2[i] -= mod;
    }
}
int main () {
    int n;
    long long k, rez = 1;
    cin >> n >> k;
    k--;
    precalc ( n );
    for ( int i = 1; i <= n; i++ ) {
        if ( k % 2 ) {
            rez = rez + p2[n - i];
            if ( rez >= mod )
                rez -= mod;
        }
        k /= 2;
    }
    cout << rez;
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 276 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 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 304 KB Output is correct
3 Correct 1 ms 276 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 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 304 KB Output is correct
3 Correct 1 ms 276 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 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 296 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 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 460 KB Output is correct
15 Correct 6 ms 4044 KB Output is correct