結果
| 問題 |
No.2016 Countdown Divisors
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-07-22 22:45:41 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,182 bytes |
| コンパイル時間 | 71 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 07:17:26 |
| 合計ジャッジ時間 | 1,874 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 19 |
ソースコード
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 lim = mce(msq(x))
local primepos = 1
local dv = primes[primepos]
local ans = 1
while primepos <= prime_num and dv <= lim do
if x % dv == 0 then
local cnt = 1
x = mfl(x / dv)
while x % dv == 0 do
x = mfl(x / dv)
cnt = cnt + 1
end
ans = ans * (cnt + 1)
lim = mce(msq(x))
end
if primepos == prime_num then break end
primepos = primepos + 1
dv = primes[primepos]
end
if x ~= 1 then
ans = ans * 2
end
return ans
end
local primes = getprimes(100000)
local t = {}
t[1], t[3], t[4], t[5], t[7], t[8] = 1,1,1,1,1,1
local q = io.read("*n")
for iq = 1, q do
local n = io.read("*n")
print(t[n] and 1 or 2)
end