結果
| 問題 |
No.2493 K-th in L2 with L1
|
| ユーザー |
|
| 提出日時 | 2023-10-19 00:12:54 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 565 ms / 2,000 ms |
| コード長 | 1,091 bytes |
| コンパイル時間 | 107 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-09-18 20:11:12 |
| 合計ジャッジ時間 | 2,640 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
input_line = gets.chomp!.to_i
questions = []
for i in 1..input_line
input_line2 = gets.chomp!.split(' ').map{|n| n.to_i}
questions.push(input_line2)
end
questions.each do |input_line2|
good_points = []
for i in 0..input_line2[0]
point = []
point.push(i)
point.push(input_line2[0] - i)
good_points.push(point)
point2 = point.dup
point2[0] = point2[0] * -1
if (!good_points.include?(point2)) then
good_points.push(point2)
end
point3 = point2.dup
point3[1] = point3[1] * -1
if (!good_points.include?(point3)) then
good_points.push(point3)
end
point4 = point3.dup
point4[0] = point4[0] * -1
if (!good_points.include?(point4)) then
good_points.push(point4)
end
end
distances = []
good_points.each do |point|
distance = Math.sqrt((point[0] - 0)**2 + (point[1] - 0)**2)
distances.push(distance)
end
if (distances.length < input_line2[1]) then
puts 'No'
else
puts 'Yes'
serach = distances.sort[input_line2[1] - 1]
index = distances.index(serach)
target_point = good_points[index]
puts target_point.join(' ')
end
end