# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
464356 |
2021-08-13T05:31:22 Z |
tengiz05 |
Rack (eJOI19_rack) |
C++17 |
|
19 ms |
15436 KB |
#include <bits/stdc++.h>
using i64 = long long;
constexpr int P = 1000000007;
constexpr i64 inf = 2e18;
int norm(int x) {
if (x < 0) x += P;
if (x >= P) x -= P;
return x;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n, k;
std::cin >> n >> k;
k--;
std::vector<i64> mpw(n + 1, 1), pw(n + 1, 1);
for (int i = 1; i <= n; i++) {
mpw[i] = mpw[i - 1] * 2 % P;
pw[i] = std::min(pw[i - 1] * 2, inf);
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (k >= pw[n - i - 1]) {
ans = norm(ans + mpw[i]);
k -= pw[n - i - 1];
}
}
std::cout << norm(ans + 1) << "\n";
return 0;
}
/*
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
372 KB |
Output is correct |
14 |
Correct |
2 ms |
1100 KB |
Output is correct |
15 |
Correct |
19 ms |
15436 KB |
Output is correct |