結果

問題 No.933 おまわりさんこいつです
ユーザー 👑 obakyanobakyan
提出日時 2019-11-30 21:05:00
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 5,464 KB
実行使用メモリ 13,328 KB
最終ジャッジ日時 2023-08-13 09:42:06
合計ジャッジ時間 1,873 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 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,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 33 ms
4,376 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 18 ms
4,800 KB
testcase_20 AC 62 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 170 ms
13,328 KB
testcase_24 AC 123 ms
11,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local function lltonumber(str)
  local ret = 0LL
  local sign = str:sub(1, 1) ~= "-"
  local begin = sign and 1 or 2
  for i = begin, #str do
    ret = ret * 10LL
    ret = ret + tonumber(str:sub(i, i))
  end
  if not sign then ret = ret * -1LL end
  return ret
end

local n = io.read("*n", "*l")
local s = io.read()
local a = 1
for ss in s:gmatch("%d+") do
  local p = lltonumber(ss)
  if p == 0LL then
    a = -1
    break
  else
    p = p % 9LL
    local str = tostring(p):gsub("LL", "")
    local p32 = tonumber(str)
    a = (a * p32) % 9
  end
end
if a == -1 then
  print(0)
elseif a == 0 then
  print(9)
else
  print(a)
end
0