結果

問題 No.106 素数が嫌い!2
ユーザー 👑 obakyanobakyan
提出日時 2019-04-28 23:25:43
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 4,633 ms / 5,000 ms
コード長 458 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 10:47:07
合計ジャッジ時間 25,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 180 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 993 ms
4,380 KB
testcase_05 AC 4,447 ms
4,376 KB
testcase_06 AC 4,633 ms
4,376 KB
testcase_07 AC 4,630 ms
4,376 KB
testcase_08 AC 63 ms
4,376 KB
testcase_09 AC 98 ms
4,380 KB
testcase_10 AC 4,630 ms
4,384 KB
testcase_11 AC 1,375 ms
4,380 KB
testcase_12 AC 3,051 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, k = io.read("*n", "*n")
local cnt = 0
for a = 2, n do
  local lim = math.ceil(math.sqrt(a))
  local ta = a
  local denom = 2
  local c = 0
  while(denom <= lim) do
    if(ta % denom == 0) then
      c = c + 1
      if(k <= c) then break end
      while(ta % denom == 0) do
        ta = ta / denom
      end
    end
    denom = denom + (denom == 2 and 1 or 2)
  end
  if(ta ~= 1) then c = c + 1 end
  if(k <= c) then cnt = cnt + 1 end
end
print(cnt)
0