結果

問題 No.1429 Simple Dowsing
ユーザー simansiman
提出日時 2021-03-19 18:51:26
言語 Ruby
(3.3.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 11,360 KB
実行使用メモリ 31,416 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-24 10:15:22
合計ジャッジ時間 3,374 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
31,340 KB
testcase_01 AC 99 ms
31,320 KB
testcase_02 AC 96 ms
31,416 KB
testcase_03 AC 98 ms
31,004 KB
testcase_04 AC 100 ms
31,356 KB
testcase_05 AC 95 ms
31,300 KB
testcase_06 AC 97 ms
31,284 KB
testcase_07 AC 98 ms
31,008 KB
testcase_08 AC 97 ms
31,008 KB
testcase_09 AC 96 ms
31,168 KB
testcase_10 AC 98 ms
30,964 KB
testcase_11 AC 95 ms
30,940 KB
testcase_12 AC 98 ms
31,328 KB
testcase_13 AC 97 ms
31,308 KB
testcase_14 AC 98 ms
31,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def query(a, b)
  STDOUT.puts("? #{a} #{b}")
  STDOUT.flush
  gets.to_i
end

d1 = query(0, 0)
d2 = query(0, 100)

0.upto(100) do |a|
  0.upto(100) do |b|
    e1 = a ** 2 + b ** 2
    e2 = a ** 2 + (100 - b) ** 2

    if e1 == d1 && e2 == d2
      STDOUT.puts("! #{a} #{b}")
      STDOUT.flush
      exit
    end
  end
end
0