結果

問題 No.1058 素敵な数
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-07 03:43:02
言語 Ruby
(3.3.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 237 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-09-18 12:27:42
合計ジャッジ時間 1,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
15,084 KB
testcase_01 AC 92 ms
15,124 KB
testcase_02 AC 95 ms
15,080 KB
testcase_03 AC 94 ms
15,088 KB
testcase_04 AC 93 ms
15,252 KB
testcase_05 AC 91 ms
15,348 KB
testcase_06 AC 91 ms
15,196 KB
testcase_07 AC 91 ms
15,088 KB
testcase_08 AC 91 ms
15,080 KB
testcase_09 AC 90 ms
15,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'
n=gets.to_i
if n==1 then
	puts 1
else
	p1=100001
	ans=1
	ps=[]
	m=n-2
	while n>1 do
		if p1.prime? then
			n-=1
			ps<<p1
		end
		p1+=2
	end
	ans=[]
	ps.each{|x|
		ps.each{|y|
			ans<<x*y
		}
	}
	puts ans.uniq.sort[m]
end
0