結果
問題 | No.2394 部分和乗総和 |
ユーザー | 👑 obakyan |
提出日時 | 2023-07-29 09:24:51 |
言語 | Lua (LuaJit 2.1.1696795921) |
結果 |
WA
|
実行時間 | - |
コード長 | 715 bytes |
コンパイル時間 | 132 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 9,172 KB |
最終ジャッジ日時 | 2024-04-16 16:09:52 |
合計ジャッジ時間 | 4,545 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 74 ms
5,376 KB |
testcase_14 | AC | 273 ms
5,376 KB |
testcase_15 | AC | 295 ms
5,376 KB |
testcase_16 | AC | 404 ms
6,012 KB |
testcase_17 | AC | 798 ms
9,172 KB |
testcase_18 | AC | 817 ms
9,036 KB |
testcase_19 | AC | 791 ms
9,160 KB |
testcase_20 | WA | - |
ソースコード
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(0) 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)