This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |