結果

問題 No.246 質問と回答
ユーザー nonokai10nonokai10
提出日時 2018-03-28 23:30:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 11,296 KB
実行使用メモリ 31,456 KB
平均クエリ数 31.30
最終ジャッジ日時 2023-09-23 20:27:04
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
31,456 KB
testcase_01 AC 111 ms
30,532 KB
testcase_02 AC 110 ms
30,804 KB
testcase_03 AC 112 ms
30,728 KB
testcase_04 AC 108 ms
30,688 KB
testcase_05 AC 109 ms
30,856 KB
testcase_06 AC 111 ms
31,156 KB
testcase_07 AC 108 ms
31,124 KB
testcase_08 AC 110 ms
31,100 KB
testcase_09 AC 110 ms
30,836 KB
testcase_10 AC 110 ms
31,200 KB
testcase_11 AC 111 ms
31,040 KB
testcase_12 AC 108 ms
31,328 KB
testcase_13 AC 108 ms
30,632 KB
testcase_14 AC 113 ms
31,244 KB
testcase_15 AC 110 ms
30,756 KB
testcase_16 AC 107 ms
30,732 KB
testcase_17 AC 109 ms
31,312 KB
testcase_18 AC 106 ms
31,216 KB
testcase_19 AC 112 ms
31,084 KB
testcase_20 AC 107 ms
30,644 KB
testcase_21 AC 109 ms
31,404 KB
testcase_22 AC 109 ms
31,124 KB
testcase_23 AC 108 ms
31,200 KB
testcase_24 AC 108 ms
31,392 KB
testcase_25 AC 108 ms
30,744 KB
testcase_26 AC 113 ms
30,644 KB
testcase_27 AC 108 ms
30,708 KB
testcase_28 AC 110 ms
30,976 KB
testcase_29 AC 110 ms
31,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

min = 1
max = 10**9
while max - min > 1
  puts "? #{(max + min)/2}"
  STDOUT.flush
  ans = gets.to_i
  case ans
  when 0
    max = (max + min)/2 - 1
  when 1
    min = (max + min)/2
  end
end
puts "? #{max}"
STDOUT.flush
ans = gets.to_i
case ans
when 0
  puts "! #{min}"
when 1
  puts "! #{max}"
end
0