結果
問題 | No.1569 Nixoracci's Number |
ユーザー | 👑 obakyan |
提出日時 | 2021-08-10 20:01:32 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
AC
|
実行時間 | 1,246 ms / 2,000 ms |
コード長 | 1,793 bytes |
コンパイル時間 | 211 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 22:12:16 |
合計ジャッジ時間 | 9,009 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 845 ms
6,944 KB |
testcase_05 | AC | 58 ms
6,940 KB |
testcase_06 | AC | 1,246 ms
6,940 KB |
testcase_07 | AC | 4 ms
6,940 KB |
testcase_08 | AC | 114 ms
6,944 KB |
testcase_09 | AC | 11 ms
6,940 KB |
testcase_10 | AC | 60 ms
6,944 KB |
testcase_11 | AC | 181 ms
6,944 KB |
testcase_12 | AC | 444 ms
6,940 KB |
testcase_13 | AC | 615 ms
6,944 KB |
testcase_14 | AC | 87 ms
6,944 KB |
testcase_15 | AC | 827 ms
6,940 KB |
testcase_16 | AC | 135 ms
6,940 KB |
testcase_17 | AC | 72 ms
6,940 KB |
testcase_18 | AC | 201 ms
6,940 KB |
testcase_19 | AC | 64 ms
6,944 KB |
testcase_20 | AC | 1,083 ms
6,944 KB |
testcase_21 | AC | 474 ms
6,944 KB |
testcase_22 | AC | 121 ms
6,940 KB |
testcase_23 | AC | 1,224 ms
6,944 KB |
ソースコード
local mfl, mce = math.floor, math.ceil local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local n, k = io.read():match("(%d+) (%d+)") n = tonumber(n) local strk = k k = lltonumber(k) local str = io.read() local dlim = 60 local mat = {} for i = 1, n - 1 do mat[i] = {} for j = 1, n do mat[i][j] = 1 + i == j and 1 or 0 end end mat[n] = {} for j = 1, n do mat[n][j] = 1 end local vec = {} for i = 1, dlim do vec[i] = {} end local a = {} do local i = 0 for w in str:gmatch("%d+") do i = i + 1 w = lltonumber(w) a[i] = w assert(w <= 1000000000000000000LL) for j = 1, dlim do vec[j][i] = w % 2LL == 0 and 0 or 1 w = w / 2LL end end end if #strk <= 3 then local tk = tonumber(strk) if tk <= n then print(a[tk]) os.exit() end end k = k - n local tmpmat = {} for i = 1, n do tmpmat[i] = {} end local tmpvec = {} local function matmat() for i = 1, n do for j = 1, n do local v = 0 for k = 1, n do v = v + mat[i][k] * mat[k][j] end tmpmat[i][j] = v % 2 end end for i = 1, n do for j = 1, n do mat[i][j] = tmpmat[i][j] end end end local function matvec() for d = 1, dlim do local vd = vec[d] for i = 1, n do local v = 0 for k = 1, n do v = v + mat[i][k] * vec[d][k] end tmpvec[i] = v % 2 end for i = 1, n do vec[d][i] = tmpvec[i] end end end while 0LL < k do if k % 2LL == 1LL then matvec() end matmat() k = k / 2LL end local ret = 0LL local mul = 1LL for i = 1, dlim do if vec[i][n] == 1 then ret = ret + mul end mul = mul + mul end ret = tostring(ret):gsub("LL", "") print(ret) -- print(os.clock())