結果

問題 No.1058 素敵な数
ユーザー 👑 obakyanobakyan
提出日時 2020-05-22 21:32:15
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 115 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-15 16:00:27
合計ジャッジ時間 2,140 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,248 KB
testcase_01 AC 173 ms
7,936 KB
testcase_02 AC 182 ms
7,936 KB
testcase_03 AC 172 ms
7,936 KB
testcase_04 AC 175 ms
7,936 KB
testcase_05 AC 171 ms
7,936 KB
testcase_06 AC 171 ms
7,936 KB
testcase_07 AC 173 ms
7,936 KB
testcase_08 AC 173 ms
7,936 KB
testcase_09 AC 172 ms
7,936 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