結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 👑 obakyanobakyan
提出日時 2019-05-05 16:16:37
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 192 ms / 1,000 ms
コード長 535 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 71,916 KB
最終ジャッジ日時 2023-09-07 08:38:47
合計ジャッジ時間 2,120 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 13 ms
6,736 KB
testcase_20 AC 40 ms
19,552 KB
testcase_21 AC 0 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 75 ms
37,080 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 36 ms
19,732 KB
testcase_33 AC 192 ms
71,916 KB
testcase_34 AC 174 ms
71,824 KB
testcase_35 AC 67 ms
37,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, l = io.read("*n", "*n")
local maxdiff = math.floor(l / (n - 1))

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 = math.floor(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local primes = getprimes(maxdiff)

local cnt = 0
for i = 1, #primes do
  local p = primes[i]
  cnt = cnt + (l - p * (n - 1) + 1)
end
print(cnt)
0