結果

問題 No.1058 素敵な数
ユーザー 👑 obakyanobakyan
提出日時 2020-05-22 21:32:15
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 5,392 KB
実行使用メモリ 8,788 KB
最終ジャッジ日時 2023-07-28 06:34:25
合計ジャッジ時間 2,860 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 219 ms
7,480 KB
testcase_02 AC 224 ms
7,460 KB
testcase_03 AC 223 ms
7,472 KB
testcase_04 AC 222 ms
8,788 KB
testcase_05 AC 223 ms
7,584 KB
testcase_06 AC 224 ms
7,504 KB
testcase_07 AC 219 ms
7,560 KB
testcase_08 AC 219 ms
7,500 KB
testcase_09 AC 224 ms
7,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mfl, mce = math.floor, math.ceil

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local primes = getprimes(110000)
local n = io.read("*n")
if n == 1 then print(1) os.exit() end
local t = {}
for i = 1, #primes do
  if 100000 < primes[i] then
    table.insert(t, primes[i])
  end
end
local r = {}
for i = 1, #t do
  for j = i, #t do
    table.insert(r, t[i] * t[j])
  end
end
table.sort(r)
print(r[n - 1])
0