# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237671 |
2020-06-08T08:56:26 Z |
RiscadoA |
Rack (eJOI19_rack) |
C++14 |
|
6 ms |
384 KB |
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;
int64_t fast_pow(int64_t x, int64_t y) {
x %= MOD;
if (x == 0) {
return 0;
}
int64_t res = 1;
while (y > 0) {
if (y % 2 == 1) {
res = (res * x) % MOD;
}
y >>= 1;
x = (x * x) % MOD;
}
return res;
}
int64_t solve(int64_t n, int64_t k) {
if (n == 0) {
if (k != 0) {
abort();
}
return 1;
}
if (k % 2 == 0) {
return solve(n - 1, k / 2);
} else {
int64_t k2 = 0;
if (k > 1) {
k2 = k / 2;
}
return (fast_pow(2, n - 1) + solve(n - 1, k2)) % MOD;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int64_t n, k;
cin >> n >> k;
cout << solve(n, k - 1) << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |