제출 #254759

#제출 시각아이디문제언어결과실행 시간메모리
254759model_codeGuess the number (BOI20_guess)Java
100 / 100
110 ms10528 KiB
import java.io.*; import java.util.*; public class Guess { static class Tokenizer extends StreamTokenizer { public Tokenizer(Reader r) { super(r); resetSyntax(); whitespaceChars(0, ' '); wordChars(' '+1, 127); parseNumbers(); } public int nextInt() throws IOException { return (int)nextDouble(); } public long nextLong() throws IOException { return (long)nextDouble(); // Up to +/- 10^15 } public double nextDouble() throws IOException { nextToken(); return nval; } public String nextString() throws IOException { nextToken(); return sval; } } public static void main(String[] args) throws IOException { Tokenizer in = new Tokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int a = 1, b = in.nextInt(); while (a < b) { int m = (a + b) / 2; out.print("? "); out.println(m); out.flush(); int ans = in.nextInt(); if (ans < 0) { a = m + 1; } else if (ans > 0) { b = m - 1; } else { a = b = m; } } out.print("= "); out.println(a); out.close(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...