結果

問題 No.933 おまわりさんこいつです
ユーザー 👑 obakyanobakyan
提出日時 2019-11-30 21:05:00
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 68 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 9,476 KB
最終ジャッジ日時 2024-05-01 03:14:20
合計ジャッジ時間 1,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 9 ms
6,940 KB
testcase_16 AC 25 ms
6,944 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 15 ms
6,940 KB
testcase_20 AC 38 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 131 ms
9,476 KB
testcase_24 AC 98 ms
8,644 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