結果

問題 No.2394 部分和乗総和
ユーザー 👑 obakyan
提出日時 2023-07-29 09:25:42
言語 Lua
(LuaJit 2.1.1734355927)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 7,204 KB
実行使用メモリ 9,168 KB
最終ジャッジ日時 2024-10-07 13:24:38
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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, m, mod = io.read():match("(%d+) (%d+) (%d+)")
n = tonumber(n)
m = lltonumber(m)
mod = lltonumber(mod)
m = m % mod
if m == 0LL then
  print(1) os.exit()
end
local function modpow(pow)
  local res = 1LL
  local src = m
  while 0LL < pow do
    if pow % 2LL == 1LL then
      res = (res * src) % mod
    end
    src = (src * src) % mod
    pow = pow / 2LL
  end
  return res
end
local ans = 1LL
local s = io.read()
for w in s:gmatch("%d+") do
  w = lltonumber(w)
  ans = ans * (1LL + modpow(w))
  ans = ans % mod
end
ans = tostring(ans):gsub("LL", "")
print(ans)
0