# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1097485 | vjudge1 | Rack (eJOI19_rack) | C++17 | 1 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |