Submission #439626

# Submission time Handle Problem Language Result Execution time Memory
439626 2021-06-30T11:35:24 Z LucaIlie Rack (eJOI19_rack) C
100 / 100
8 ms 4172 KB
#include <stdio.h>

#define MAX_N 1000000
#define MAX_LG 62
#define MOD 1000000007

int p2mod[MAX_N + 1];
long long p2[MAX_LG + 1];

int main() {
    int n, r, i;
    long long k;

    scanf( "%d%lld", &n, &k );
    k--;

    p2[0] = 1;
    for ( i = 1; i <= MAX_LG; i++ )
        p2[i] = p2[i - 1] * 2;
    p2mod[0] = 1;
    for ( i = 1; i <= MAX_N; i++ )
        p2mod[i] = (p2mod[i - 1] * 2) % MOD;

    r = 0;
    for ( i = MAX_LG; i >= 0; i-- ) {
        if ( (k / p2[i]) % 2 == 1 )
            r = (r + p2mod[n - 1 - i]) % MOD;
    }

    printf( "%d", r + 1 );

    return 0;
}

Compilation message

rack.c: In function 'main':
rack.c:14:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf( "%d%lld", &n, &k );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4172 KB Output is correct
2 Correct 7 ms 4172 KB Output is correct
3 Correct 8 ms 4172 KB Output is correct
4 Correct 6 ms 4172 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4172 KB Output is correct
2 Correct 7 ms 4172 KB Output is correct
3 Correct 8 ms 4172 KB Output is correct
4 Correct 6 ms 4172 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 6 ms 4172 KB Output is correct
8 Correct 7 ms 4172 KB Output is correct
9 Correct 6 ms 4172 KB Output is correct
10 Correct 7 ms 4076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4172 KB Output is correct
2 Correct 7 ms 4172 KB Output is correct
3 Correct 8 ms 4172 KB Output is correct
4 Correct 6 ms 4172 KB Output is correct
5 Correct 7 ms 4172 KB Output is correct
6 Correct 6 ms 4172 KB Output is correct
7 Correct 6 ms 4172 KB Output is correct
8 Correct 7 ms 4172 KB Output is correct
9 Correct 6 ms 4172 KB Output is correct
10 Correct 7 ms 4076 KB Output is correct
11 Correct 7 ms 4172 KB Output is correct
12 Correct 7 ms 4084 KB Output is correct
13 Correct 6 ms 4172 KB Output is correct
14 Correct 6 ms 4172 KB Output is correct
15 Correct 6 ms 4172 KB Output is correct