結果

問題 No.1058 素敵な数
ユーザー simansiman
提出日時 2020-10-08 19:01:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 213 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 21,128 KB
最終ジャッジ日時 2023-09-27 11:57:33
合計ジャッジ時間 4,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 323 ms
21,000 KB
testcase_01 AC 321 ms
20,908 KB
testcase_02 AC 321 ms
21,064 KB
testcase_03 AC 324 ms
20,884 KB
testcase_04 AC 328 ms
21,128 KB
testcase_05 AC 326 ms
20,864 KB
testcase_06 AC 328 ms
21,020 KB
testcase_07 AC 323 ms
20,840 KB
testcase_08 AC 323 ms
20,888 KB
testcase_09 AC 320 ms
20,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

N = gets.to_i
primes = Prime.each(1_000_000).to_a.select { |x| x > 10 ** 5 }.take(N)

if N == 1
  puts 1
else
  nums = primes.product(primes).map { |a, b| a * b }.uniq.sort
  puts nums[N - 2]
end
0