結果

問題 No.2357 Guess the Function
ユーザー simansiman
提出日時 2023-06-24 18:36:12
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 266 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 11,520 KB
実行使用メモリ 31,532 KB
平均クエリ数 2.91
最終ジャッジ日時 2023-09-14 14:13:31
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
30,912 KB
testcase_01 WA -
testcase_02 AC 99 ms
30,932 KB
testcase_03 AC 101 ms
31,304 KB
testcase_04 AC 101 ms
31,232 KB
testcase_05 WA -
testcase_06 AC 100 ms
30,940 KB
testcase_07 AC 97 ms
30,892 KB
testcase_08 WA -
testcase_09 AC 97 ms
30,912 KB
testcase_10 AC 101 ms
31,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def send_query(x)
  STDOUT.puts("? #{x}")
  STDOUT.flush

  gets.to_i
end

c = send_query(100)

if c == 99
  STDOUT.puts("! 99 100")
else
  b = send_query(100 - c - 1) + 1
  a = (1...b).find { |x| (x + 100) % b == c }

  STDOUT.puts("! #{a} #{b}")
end

STDOUT.flush
0