結果

問題 No.246 質問と回答
ユーザー 👑 horiesinitihoriesiniti
提出日時 2017-06-27 10:25:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 31,448 KB
平均クエリ数 39.33
最終ジャッジ日時 2023-09-23 20:24:23
合計ジャッジ時間 5,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
30,744 KB
testcase_01 AC 123 ms
31,372 KB
testcase_02 AC 123 ms
30,944 KB
testcase_03 AC 121 ms
30,872 KB
testcase_04 AC 123 ms
31,056 KB
testcase_05 AC 124 ms
31,080 KB
testcase_06 AC 125 ms
31,200 KB
testcase_07 AC 125 ms
30,812 KB
testcase_08 AC 124 ms
31,124 KB
testcase_09 AC 122 ms
31,000 KB
testcase_10 AC 122 ms
31,012 KB
testcase_11 AC 124 ms
30,996 KB
testcase_12 AC 124 ms
30,828 KB
testcase_13 AC 124 ms
31,048 KB
testcase_14 AC 125 ms
31,092 KB
testcase_15 AC 125 ms
30,840 KB
testcase_16 AC 123 ms
31,032 KB
testcase_17 AC 122 ms
31,260 KB
testcase_18 AC 122 ms
31,148 KB
testcase_19 AC 123 ms
30,836 KB
testcase_20 AC 124 ms
31,172 KB
testcase_21 AC 123 ms
30,688 KB
testcase_22 AC 123 ms
30,936 KB
testcase_23 AC 124 ms
30,664 KB
testcase_24 AC 124 ms
30,892 KB
testcase_25 AC 124 ms
31,388 KB
testcase_26 AC 123 ms
31,448 KB
testcase_27 AC 125 ms
31,368 KB
testcase_28 AC 124 ms
30,760 KB
testcase_29 AC 125 ms
31,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(d,u)
	if d==u then
		puts ["!",d]*" "
		STDOUT.flush
	else
		m=(d+u)/2
		puts ["?",m]*" "
		STDOUT.flush
		x=gets.to_i
		if x==1 then
			puts ["?",m+1]*" "
			STDOUT.flush
			if gets.to_i==0 then
				puts ["!",m]*" "
				STDOUT.flush
				return 
			end
		end
		if x==0 then
			f(d,m)
		else
			f(m+1,u)
		end
	end
end
f(1,10**9)
0