結果

問題 No.988 N×Mマス計算(総和)
ユーザー 👑 obakyanobakyan
提出日時 2020-02-15 19:48:48
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 5,208 KB
実行使用メモリ 12,192 KB
最終ジャッジ日時 2023-09-20 12:04:40
合計ジャッジ時間 1,878 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 28 ms
5,196 KB
testcase_11 AC 60 ms
9,700 KB
testcase_12 AC 90 ms
10,952 KB
testcase_13 AC 41 ms
7,212 KB
testcase_14 AC 40 ms
6,968 KB
testcase_15 AC 23 ms
4,744 KB
testcase_16 AC 65 ms
9,612 KB
testcase_17 AC 87 ms
10,744 KB
testcase_18 AC 57 ms
9,124 KB
testcase_19 AC 89 ms
10,568 KB
testcase_20 AC 89 ms
12,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, m, k = io.read("*n", "*n", "*n", "*l")
local str = io.read()
local op = str:sub(1, 1)
local b = {}
for s in str:gmatch("(%d+)") do
  local z = 0LL + tonumber(s)
  table.insert(b, z)
end
local a = {}
for i = 1, n do
  local z = 0LL + io.read("*n")
  a[i] = z
end

local bsum = 0LL
for i = 1, m do bsum = bsum + b[i] end
local asum = 0LL
for i = 1, n do asum = asum + a[i] end
k = 0LL + k
bsum = bsum % k
asum = asum % k
if op == "+" then
  local r = (bsum * n + asum * m) % k
  local z = tostring(r):gsub("LL", "")
  print(z)
else
  local r = (bsum * asum) % k
  local z = tostring(r):gsub("LL", "")
  print(z)
end
0