Submission #439593

#TimeUsernameProblemLanguageResultExecution timeMemory
439593LucaIlieRack (eJOI19_rack)C11
40 / 100
1 ms320 KiB
#include <stdio.h>

#define MAX_N 1000000
#define MAX_LG 63
#define MOD 1000000007

long long p2[MAX_LG];

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;

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

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

    return 0;
}

Compilation message (stderr)

rack.c: In function 'main':
rack.c:13:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf( "%d%lld", &n, &k );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
rack.c:18:15: warning: iteration 62 invokes undefined behavior [-Waggressive-loop-optimizations]
   18 |         p2[i] = p2[i - 1] * 2;
      |         ~~~~~~^~~~~~~~~~~~~~~
rack.c:17:5: note: within this loop
   17 |     for ( i = 1; i <= MAX_LG; i++ )
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...