結果
問題 | No.1665 quotient replace |
ユーザー | 👑 obakyan |
提出日時 | 2022-01-09 00:14:45 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,135 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 21,312 KB |
最終ジャッジ日時 | 2024-11-14 09:59:51 |
合計ジャッジ時間 | 127,422 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,718 ms
21,152 KB |
testcase_01 | AC | 2,694 ms
21,084 KB |
testcase_02 | AC | 2,733 ms
21,236 KB |
testcase_03 | AC | 2,695 ms
21,156 KB |
testcase_04 | AC | 2,685 ms
21,152 KB |
testcase_05 | AC | 2,738 ms
21,084 KB |
testcase_06 | AC | 2,694 ms
21,216 KB |
testcase_07 | AC | 2,732 ms
21,064 KB |
testcase_08 | AC | 2,643 ms
21,188 KB |
testcase_09 | AC | 2,747 ms
20,988 KB |
testcase_10 | AC | 2,873 ms
21,004 KB |
testcase_11 | AC | 2,875 ms
20,864 KB |
testcase_12 | AC | 2,732 ms
21,160 KB |
testcase_13 | AC | 2,995 ms
21,172 KB |
testcase_14 | AC | 2,956 ms
21,180 KB |
testcase_15 | AC | 2,976 ms
21,000 KB |
testcase_16 | TLE | - |
testcase_17 | AC | 2,934 ms
20,908 KB |
testcase_18 | AC | 2,743 ms
21,312 KB |
testcase_19 | AC | 2,549 ms
20,904 KB |
testcase_20 | AC | 2,697 ms
21,088 KB |
testcase_21 | AC | 2,676 ms
21,024 KB |
testcase_22 | AC | 2,692 ms
20,924 KB |
testcase_23 | AC | 2,512 ms
20,996 KB |
testcase_24 | AC | 2,713 ms
21,060 KB |
testcase_25 | AC | 2,700 ms
21,200 KB |
testcase_26 | AC | 2,589 ms
21,048 KB |
testcase_27 | AC | 2,745 ms
21,016 KB |
testcase_28 | AC | 2,773 ms
21,080 KB |
testcase_29 | AC | 2,485 ms
20,988 KB |
testcase_30 | AC | 2,872 ms
21,260 KB |
testcase_31 | AC | 2,722 ms
20,872 KB |
testcase_32 | AC | 2,874 ms
21,244 KB |
testcase_33 | AC | 2,788 ms
21,076 KB |
testcase_34 | AC | 2,892 ms
21,084 KB |
testcase_35 | AC | 2,843 ms
21,008 KB |
testcase_36 | AC | 2,902 ms
21,084 KB |
testcase_37 | AC | 2,813 ms
21,016 KB |
testcase_38 | AC | 2,876 ms
21,024 KB |
testcase_39 | AC | 2,868 ms
21,012 KB |
testcase_40 | AC | 2,823 ms
21,160 KB |
testcase_41 | AC | 2,778 ms
21,040 KB |
testcase_42 | AC | 2,589 ms
21,084 KB |
testcase_43 | AC | 2,789 ms
21,076 KB |
ソースコード
local bxor = bit.bxor 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 local t = {} t.p = dv t.cnt = 1 x = mfl(x / dv) while x % dv == 0 do x = mfl(x / dv) t.cnt = t.cnt + 1 end table.insert(tmp, t) lim = mce(msq(x)) end if primepos == prime_num then break end primepos = primepos + 1 dv = primes[primepos] end if x ~= 1 then local t = {} t.p, t.cnt = x, 1 table.insert(tmp, t) end return tmp end local tt = {0} local function getdivisorCore(divisorparts) local m = {} local pat = 1 local len = #divisorparts local allpat = 1 for i = 1, len do allpat = allpat * (1 + divisorparts[i].cnt) end for t_i_pat = 0, allpat - 2 do local div = allpat local i_pat = t_i_pat local ret = 1 for i = 1, len do div = mfl(div / (divisorparts[i].cnt + 1)) local mul = mfl(i_pat / div) i_pat = i_pat % div for j = 1, mul do ret = ret * divisorparts[i].p end end m[tt[ret]] = true end for i = 0, 1000000 do if not m[i] then return i end end assert(false) return false end local function getdivisor(x, primes) local dvp = getdivisorparts(x, primes) return getdivisorCore(dvp) end local primes = getprimes(1000) for i = 2, 1000 * 1000 do tt[i] = getdivisor(i, primes) end -- print(os.clock()) -- os.exit() local n = io.read("*n") local ret = 0 for i = 1, n do local a = io.read("*n") ret = bxor(ret, tt[a]) end print(ret == 0 and "black" or "white")