結果
問題 | No.376 立方体のN等分 (2) |
ユーザー | 👑 obakyan |
提出日時 | 2019-05-06 23:46:22 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,270 bytes |
コンパイル時間 | 50 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-28 14:23:04 |
合計ジャッジ時間 | 13,026 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 5 ms
5,376 KB |
testcase_03 | AC | 11 ms
5,376 KB |
testcase_04 | AC | 5 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 156 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 3 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 2,267 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 3 ms
5,376 KB |
testcase_21 | AC | 2,361 ms
5,376 KB |
testcase_22 | AC | 3 ms
5,376 KB |
testcase_23 | AC | 2,400 ms
5,376 KB |
testcase_24 | AC | 2,017 ms
5,376 KB |
testcase_25 | AC | 3 ms
5,376 KB |
testcase_26 | AC | 2,547 ms
5,376 KB |
testcase_27 | AC | 3 ms
5,376 KB |
testcase_28 | AC | 4 ms
5,376 KB |
testcase_29 | AC | 4 ms
5,376 KB |
testcase_30 | AC | 4 ms
5,376 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 3 ms
5,376 KB |
testcase_36 | AC | 3 ms
5,376 KB |
testcase_37 | AC | 3 ms
5,376 KB |
testcase_38 | AC | 3 ms
5,376 KB |
testcase_39 | AC | 4 ms
5,376 KB |
ソースコード
local n = io.read("*n") 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 function getdivisorparts(x, primes) local prime_num = #primes local tmp = {} local lim = math.ceil(math.sqrt(x)) local primepos = 1 local dv = primes[primepos] while(primepos <= prime_num and dv <= lim) do if(x % dv == 0) then local asdf = {} asdf.p = dv asdf.cnt = 1 x = x / dv while(x % dv == 0) do x = x / dv asdf.cnt = asdf.cnt + 1 end table.insert(tmp, asdf) lim = math.ceil(math.sqrt(x)) end if(primepos == prime_num) then break end primepos = primepos + 1 dv = primes[primepos] end if(x ~= 1) then local asdf = {} asdf.p, asdf.cnt = x, 1 table.insert(tmp, asdf) end return tmp end local function getdivisor(divisorparts) local t = {} local pat = 1 local len = #divisorparts local allpat = 1 for i = 1, len do allpat = allpat * (divisorparts[i].cnt + 1) end for t_i_pat = 0, allpat - 1 do local div = allpat local i_pat = t_i_pat local ret = 1 for i = 1, len do div = math.floor(div / (divisorparts[i].cnt + 1)) local mul = math.floor(i_pat / div) i_pat = i_pat % div for j = 1, mul do ret = ret * divisorparts[i].p end end table.insert(t, ret) end table.sort(t) return t end local retmin, retmax = n - 1, n - 1 local primes = getprimes(math.ceil(n^(1/3))) local divisorparts = getdivisorparts(n, primes) local divisor = getdivisor(divisorparts) local dmax = math.ceil(n^(1/3)) for i = 1, #divisor do if(dmax < divisor[i]) then break end local rem = math.floor(n / divisor[i]) local remparts = getdivisorparts(rem, primes) local remdiv = getdivisor(remparts) local remlim = math.ceil(math.sqrt(rem)) for j = 1, #remdiv do if(remlim < remdiv[j]) then break end local last = math.floor(rem / remdiv[j]) retmin = math.min(retmin, divisor[i] + remdiv[j] + last - 3) end end print(retmin .. " " .. retmax)