#include <iostream>
#include <stack>
int main()
{
int q;
std::cin >> q;
while (q--)
{
long long int x, l, n;
std::cin >> x >> l >> n;
n *= 2;
long long int dis = ((l / n) + 1) * n;
if (n == 4)
{
int cur = dis % 9;
if (cur == 0 || cur == 3 || cur == 5 || cur == 6)
{
std::cout << dis << "\n";
}
else
{
std::cout << dis + 1 << "\n";
}
continue;
}
if (x % 4 == 0 || x % 4 == 3)
{
std::cout << dis << "\n";
}
else
{
std::cout << dis + 1 << "\n";
}
n /= 2;
std::stack<int> s1;
int flipped = 0;
int t2 = 0;
s1.push(0);
s1.push(0);
int counter = x;
while (counter > 0)
{
t2 = s1.top() ^ flipped;
if (t2 > 1)
s1.pop();
flipped = !flipped;
if (t2 > l)
{
--counter;
std::cout << t2 << " ";
if (counter == 0)
{
std::cout << "\n";
break;
}
}
else
{
s1.push((t2 + 2 * n) ^ flipped);
s1.push((t2 + 2 * n) ^ flipped);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Incorrect |
92 ms |
1892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
1892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
1892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
354 ms |
2376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |