Submission #1097486

# Submission time Handle Problem Language Result Execution time Memory
1097486 2024-10-07T13:08:15 Z vjudge1 Rack (eJOI19_rack) C++17
40 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int MOD = 1e9 + 7;

ll log2_floor(unsigned long long x) {
    return x ? __builtin_clzll(1) - __builtin_clzll(x) : -1;
}

ll powmod(ll b, ll p) {
    if (!p) return 1;
    long long p2 = pow(b, p >> 1);
    return (1LL * p2 * p2 * (p & 1 ? b : 1)) % MOD;
}

ll test(ll n, ll k) {
    k--;
    ll result = 1;

    while (k) {
        ll mask = k & (-k);
        result = (result + powmod(2, n - log2_floor(mask) - 1)) % MOD;
        k ^= mask;
    }

    return result % MOD;
}

int main() {
    ll n, k;
    scanf("%d %d", &n, &k);
    printf("%d\n", test(n, k));
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:33:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'll*' {aka 'long long int*'} [-Wformat=]
   33 |     scanf("%d %d", &n, &k);
      |            ~^      ~~
      |             |      |
      |             int*   ll* {aka long long int*}
      |            %lld
rack.cpp:33:16: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'll*' {aka 'long long int*'} [-Wformat=]
   33 |     scanf("%d %d", &n, &k);
      |               ~^       ~~
      |                |       |
      |                int*    ll* {aka long long int*}
      |               %lld
rack.cpp:34:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll' {aka 'long long int'} [-Wformat=]
   34 |     printf("%d\n", test(n, k));
      |             ~^     ~~~~~~~~~~
      |              |         |
      |              int       ll {aka long long int}
      |             %lld
rack.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -