結果
問題 | No.1611 Minimum Multiple with Double Divisors |
ユーザー | 👑 obakyan |
提出日時 | 2021-07-21 23:46:40 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,841 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 5,376 KB |
実行使用メモリ | 20,996 KB |
最終ジャッジ日時 | 2024-10-03 02:40:51 |
合計ジャッジ時間 | 21,251 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 282 ms
20,864 KB |
testcase_01 | AC | 251 ms
20,776 KB |
testcase_02 | AC | 259 ms
20,864 KB |
testcase_03 | AC | 256 ms
20,788 KB |
testcase_04 | AC | 256 ms
20,832 KB |
testcase_05 | AC | 254 ms
20,840 KB |
testcase_06 | AC | 245 ms
20,768 KB |
testcase_07 | AC | 247 ms
20,792 KB |
testcase_08 | AC | 256 ms
20,820 KB |
testcase_09 | AC | 257 ms
20,864 KB |
testcase_10 | AC | 174 ms
20,908 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 1,653 ms
20,824 KB |
testcase_13 | AC | 1,756 ms
20,864 KB |
testcase_14 | AC | 1,715 ms
20,864 KB |
testcase_15 | AC | 1,690 ms
20,840 KB |
testcase_16 | AC | 1,691 ms
20,736 KB |
testcase_17 | AC | 1,658 ms
20,864 KB |
testcase_18 | AC | 1,643 ms
20,828 KB |
testcase_19 | AC | 55 ms
20,768 KB |
testcase_20 | AC | 53 ms
20,852 KB |
testcase_21 | AC | 53 ms
20,820 KB |
testcase_22 | AC | 55 ms
20,768 KB |
testcase_23 | AC | 56 ms
20,864 KB |
testcase_24 | AC | 54 ms
20,756 KB |
testcase_25 | AC | 57 ms
20,772 KB |
testcase_26 | AC | 55 ms
20,772 KB |
testcase_27 | AC | 56 ms
20,864 KB |
testcase_28 | AC | 48 ms
20,856 KB |
testcase_29 | AC | 52 ms
20,864 KB |
testcase_30 | AC | 51 ms
20,928 KB |
testcase_31 | AC | 51 ms
20,764 KB |
testcase_32 | AC | 52 ms
20,772 KB |
testcase_33 | AC | 52 ms
20,828 KB |
testcase_34 | AC | 49 ms
20,864 KB |
testcase_35 | AC | 51 ms
20,864 KB |
testcase_36 | AC | 53 ms
20,832 KB |
testcase_37 | AC | 51 ms
20,832 KB |
testcase_38 | AC | 50 ms
20,996 KB |
ソースコード
local mce, mfl, msq, mmi, mma, mab = math.ceil, math.floor, math.sqrt, math.min, math.max, math.abs 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 = mfl(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 = mce(msq(x)) local primepos = 1 local dv = primes[primepos] while primepos <= prime_num and dv <= lim do if x % dv == 0 then x = mfl(x / dv) local cnt = 1 while x % dv == 0 do x = mfl(x / dv) cnt = cnt + 1 end tmp[dv] = cnt lim = mce(msq(x)) end if primepos == prime_num then break end primepos = primepos + 1 dv = primes[primepos] end if x ~= 1 then tmp[x] = 1 end return tmp end local primes = getprimes(mce(msq(31 * 100000000000))) local predvp = {0} for i = 2, 31 do predvp[i] = getdivisorparts(i, primes) end local q = io.read("*n") for iq = 1, q do local x = io.read("*n") local v = false for i = 1, #primes do local p = primes[i] if x % p ~= 0 then v = p break end end local ans = 1 * v local dvp = getdivisorparts(x, primes) local tot = 1 for k, v in pairs(dvp) do tot = tot * (1 + v) end for j = 2, ans - 1 do local dvp2 = j <= 31 and predvp[j] or getdivisorparts(j, primes) local tot2 = tot for k, v in pairs(dvp2) do if dvp[k] then tot2 = mfl(tot2 * (dvp[k] + v + 1) / (dvp[k] + 1)) else tot2 = tot2 * (v + 1) end end if tot * 2 == tot2 then ans = j break end end print(ans * x) end -- print(os.clock())