# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
675728 |
2022-12-27T19:06:43 Z |
Alma |
Rack (eJOI19_rack) |
C++17 |
|
1 ms |
212 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
ll n, k;
cin >> n >> k;
ll pos = 1, add = n;
bool inv = false;
vector<int> powMOD(n+1);
powMOD[0] = 1;
for (int i = 1; i <= n; i++) {
powMOD[i] = (powMOD[i-1] * 2) % MOD;
}
int i = 0;
while (i < n) {
if ((1 << i) > k) {
break;
}
add--;
if (inv == false) {
if ((k & (1 << i))) {
inv = true;
} else {
pos += powMOD[add];
pos %= MOD;
}
} else {
if ((k & (1 << i))) {
pos += powMOD[add];
pos %= MOD;
}
}
i++;
}
while (i < n) {
add--;
if (inv == false) {
pos += powMOD[add];
pos %= MOD;
} else {
inv = true;
}
i++;
}
cout << pos << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |