結果
問題 | No.1569 Nixoracci's Number |
ユーザー | 👑 obakyan |
提出日時 | 2021-08-10 19:52:14 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,814 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 22:03:09 |
合計ジャッジ時間 | 1,467 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 3 ms
6,940 KB |
testcase_03 | WA | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | WA | - |
testcase_08 | RE | - |
testcase_09 | WA | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
ソースコード
local mfl, mce = math.floor, math.ceil local function badd(a, b) return (a + b) % 2 end local function bmul(a, b) return a * b end 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 = {} mat[1] = {} for j = 1, n do mat[1][j] = 1 end for i = 2, n do mat[i] = {} for j = 1, n do mat[i][j] = i - 1 == j and 1 or 0 end 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 a[i] = w w = lltonumber(w) 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, dlim 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 = badd(v, bmul(mat[i][k], mat[k][j])) end tmpmat[i][j] = v 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 for i = 1, n do local v = 0 for k = 1, n do v = badd(v, bmul(mat[i][k], vec[d][k])) end tmpvec[i] = v 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][1] == 1 then ret = ret + mul end mul = mul + mul end ret = tostring(ret):gsub("LL", "") print(ret)