結果
問題 | No.1665 quotient replace |
ユーザー | 👑 obakyan |
提出日時 | 2022-01-09 00:16:24 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,171 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 6,820 KB |
実行使用メモリ | 45,456 KB |
最終ジャッジ日時 | 2024-11-14 10:02:13 |
合計ジャッジ時間 | 131,406 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,685 ms
21,148 KB |
testcase_01 | AC | 2,735 ms
21,052 KB |
testcase_02 | AC | 2,780 ms
21,080 KB |
testcase_03 | AC | 2,814 ms
21,024 KB |
testcase_04 | AC | 2,570 ms
20,912 KB |
testcase_05 | AC | 2,708 ms
21,020 KB |
testcase_06 | AC | 2,662 ms
21,156 KB |
testcase_07 | AC | 2,729 ms
21,112 KB |
testcase_08 | AC | 2,532 ms
21,024 KB |
testcase_09 | AC | 2,782 ms
21,608 KB |
testcase_10 | AC | 2,755 ms
31,800 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 2,639 ms
22,932 KB |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | AC | 2,731 ms
21,088 KB |
testcase_19 | AC | 2,673 ms
21,232 KB |
testcase_20 | AC | 2,717 ms
21,036 KB |
testcase_21 | AC | 2,753 ms
21,000 KB |
testcase_22 | AC | 2,665 ms
21,064 KB |
testcase_23 | AC | 2,841 ms
21,000 KB |
testcase_24 | AC | 2,729 ms
21,108 KB |
testcase_25 | AC | 2,749 ms
21,240 KB |
testcase_26 | AC | 2,602 ms
21,112 KB |
testcase_27 | AC | 2,689 ms
21,108 KB |
testcase_28 | AC | 2,668 ms
21,876 KB |
testcase_29 | AC | 2,597 ms
22,748 KB |
testcase_30 | AC | 2,878 ms
27,764 KB |
testcase_31 | AC | 2,948 ms
32,532 KB |
testcase_32 | TLE | - |
testcase_33 | AC | 2,801 ms
27,044 KB |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | TLE | - |
testcase_39 | AC | 2,978 ms
32,440 KB |
testcase_40 | AC | 2,964 ms
32,468 KB |
testcase_41 | AC | 2,969 ms
32,420 KB |
testcase_42 | AC | 2,588 ms
21,064 KB |
testcase_43 | AC | 2,729 ms
21,048 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", "*l") local ret = 0 local s = io.read() for w in s:gmatch("%d+") do local a = tonumber(w) ret = bxor(ret, tt[a]) end print(ret == 0 and "black" or "white")