結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
30,736 KB
testcase_01 AC 102 ms
30,780 KB
testcase_02 AC 102 ms
31,220 KB
testcase_03 AC 101 ms
30,768 KB
testcase_04 AC 103 ms
31,272 KB
testcase_05 AC 104 ms
31,060 KB
testcase_06 AC 102 ms
31,144 KB
testcase_07 AC 106 ms
31,100 KB
testcase_08 AC 101 ms
30,860 KB
testcase_09 AC 101 ms
30,744 KB
testcase_10 AC 101 ms
30,824 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 = (0...b).find { |x| (x + 100) % b == c }

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

STDOUT.flush
0