Submission #1097486

#TimeUsernameProblemLanguageResultExecution timeMemory
1097486vjudge1Rack (eJOI19_rack)C++17
40 / 100
1 ms348 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...