結果

問題 No.106 素数が嫌い!2
ユーザー 👑 obakyanobakyan
提出日時 2019-04-28 23:23:42
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 4,647 ms / 5,000 ms
コード長 426 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 10:38:48
合計ジャッジ時間 30,842 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,673 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1,660 ms
4,380 KB
testcase_05 AC 4,646 ms
4,380 KB
testcase_06 AC 4,646 ms
4,380 KB
testcase_07 AC 4,647 ms
4,380 KB
testcase_08 AC 89 ms
4,380 KB
testcase_09 AC 99 ms
4,376 KB
testcase_10 AC 4,642 ms
4,376 KB
testcase_11 AC 1,383 ms
4,376 KB
testcase_12 AC 4,362 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
      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