Submission #1097485

#TimeUsernameProblemLanguageResultExecution timeMemory
1097485vjudge1Rack (eJOI19_rack)C++17
40 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long int; const int MOD = 1e9 + 7; int log2_floor(unsigned long long x) { return x ? __builtin_clzll(1) - __builtin_clzll(x) : -1; } int pow(int b, int p) { if (!p) return 1; int p2 = pow(b, p >> 1); return (1LL * p2 * p2 * (p & 1 ? b : 1)) % MOD; } int test(int n, ll k) { k--; ll result = 1; while (k) { ll mask = k & (-k); result = (result + pow(2, n - log2_floor(mask) - 1)) % MOD; k ^= mask; } return result % MOD; } int main() { int 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: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...