#include "bits/stdc++.h"
using namespace std;
vector<long long> _1 = {0, 1, 1, 0};
vector<long long> _2 = {0, 1, 1, 0, 1, 0, 0, 1};
vector<long long> _3 = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1};
vector<long long> _4 = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
long long q, x, l, n;
cin>>q;
while(q--){
cin>>x>>l>>n;
long long Izquierda = 0;
long long Derecha = l;
long long Mejor = 0;
while(1){
long long Promedio = (Izquierda + Derecha) / 2;
if(Promedio * 2 * n < l){
Izquierda = Promedio + 1;
} else {
Derecha = Promedio - 1;
Mejor = Promedio;
}
if(Izquierda >= Derecha + 1) break;
}
long long Respuesta = Mejor * 2 * n;
bool Sufridor = Mejor + 1 - n == l;
if(Mejor % 2 == 1 and !Sufridor){
x--;
x %= 4;
cout<<Respuesta + _1[x]<<"\n";
} else if(Mejor % 2 == 0 and !Sufridor){
x--;
x %= 8;
cout<<Respuesta + _2[x]<<"\n";
} else if(Mejor % 2 == 1 and Sufridor){
x--;
x %= 32;
cout<<Respuesta + _3[x]<<"\n";
} else {
x--;
x %= 64;
cout<<Respuesta + _4[x]<<"\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
6228 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |