結果
| 問題 |
No.144 エラトステネスのざる
|
| ユーザー |
👑 |
| 提出日時 | 2019-04-29 11:11:41 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 740 bytes |
| コンパイル時間 | 84 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 02:30:32 |
| 合計ジャッジ時間 | 15,481 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 TLE * 3 |
ソースコード
local n, p = io.read("*n", "*n")
local function getyakusuu(x)
local tmp = {}
local lim = math.ceil(math.sqrt(x))
local dv = 2
while(1 < x and dv <= lim) do
if(x % dv == 0) then
tmp[dv] = 1
x = x / dv
while(x % dv == 0) do
x = x / dv
tmp[dv] = tmp[dv] + 1
end
end
if(dv == 2) then dv = 3
elseif(dv == 3) then dv = 5
elseif(dv % 3 == 1) then dv = dv + 4
else dv = dv + 2 end
end
if(x ~= 1) then tmp[x] = 1 end
local cnt = 1
for k, v in pairs(tmp) do
cnt = cnt * (v + 1)
end
return cnt
end
local tot = 0
for i = 2, n do
local z = getyakusuu(i) - 2
if(z == 0) then tot = tot + 1
else tot = tot + (1 - p)^z end
end
print(string.format("%.8f", tot))