git reimport
This commit is contained in:
43
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.java
Normal file
43
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int testCount = in.nextInt();
|
||||
|
||||
for (int test = 0; test < testCount; test++) {
|
||||
int a = in.nextInt();
|
||||
int b = in.nextInt();
|
||||
int n = in.nextInt();
|
||||
|
||||
while (true) {
|
||||
int m = (a + b + 1) / 2;
|
||||
|
||||
out.println(m);
|
||||
out.flush();
|
||||
|
||||
String resp = in.nextString();
|
||||
|
||||
if (resp.equals("CORRECT")) {
|
||||
break;
|
||||
} else if (resp.equals("TOO_BIG")) {
|
||||
b = m - 1;
|
||||
} else if (resp.equals("TOO_SMALL")) {
|
||||
a = m + 1;
|
||||
} else {
|
||||
System.out.println("WTF");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user