結果

問題 No.2493 K-th in L2 with L1
ユーザー Merry-AmorMerry-Amor
提出日時 2023-10-19 00:12:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 631 ms / 2,000 ms
コード長 1,091 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 11,940 KB
実行使用メモリ 16,536 KB
最終ジャッジ日時 2023-10-19 00:12:58
合計ジャッジ時間 3,175 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
16,068 KB
testcase_01 AC 530 ms
16,536 KB
testcase_02 AC 631 ms
16,516 KB
testcase_03 AC 555 ms
16,524 KB
testcase_04 AC 84 ms
16,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
0