#include "bits/stdc++.h"
using namespace std;
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;
if(Mejor % 2 == 1){
if(x % 2 == 1) cout<<Respuesta<<"\n";
else cout<<Respuesta + 1<<"\n";
} else {
if(x == 1) cout<<Respuesta<<"\n";
else {
x--;
x %= 4;
if(x < 2) cout<<Respuesta + 1<<"\n";
else cout<<Respuesta<<"\n";
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 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 |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
54 ms |
6224 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |