結果

問題 No.1429 Simple Dowsing
ユーザー materialmaterial
提出日時 2021-03-14 16:13:55
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 11,376 KB
実行使用メモリ 31,636 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-24 10:07:53
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
31,008 KB
testcase_01 AC 111 ms
30,872 KB
testcase_02 WA -
testcase_03 AC 108 ms
30,880 KB
testcase_04 AC 109 ms
30,892 KB
testcase_05 WA -
testcase_06 AC 109 ms
31,332 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 107 ms
30,724 KB
testcase_13 AC 108 ms
31,040 KB
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def candidate(p, q, d)
  ts = []
  (0..100).each do |y|
    (0..100).each do |x|
      if ((p - x) ** 2 + (q - y) ** 2) == d then
        ts.push([x, y])
      end
    end
  end
  return ts
end

def intersection(s, t)
  u = []
  s.each do |x|
    u.push(x) if t.include?(x)
  end
  return u
end

def main(argv)
  p = 50
  q = 50

  puts "? #{p} #{q}"
  STDOUT.flush
  d = gets.chomp.to_i

  ts = candidate(p, q, d)

  p = ts[0][0]
  q = ts[0][1]

  puts "? #{p} #{q}"
  STDOUT.flush
  d = gets.chomp.to_i

  ts = candidate(p, q, d)

  p = ts[0][0]
  q = ts[0][1]

  puts "! #{p} #{q}"
  STDOUT.flush
end

main(ARGV) if self.to_s == 'main'
0