結果

問題 No.167 N^M mod 10
ユーザー 👑 obakyanobakyan
提出日時 2019-04-09 23:02:27
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 624 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 00:28:41
合計ジャッジ時間 1,055 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = io.read()
m = io.read()
nl = tonumber(string.sub(n, #n, #n))
mnum = 0
if(#m == 1) then mnum = tonumber(m) else
  mnum = 100 + tonumber(string.sub(m, #m - 1, #m))
end
if(mnum == 0) then
  print(1)
elseif(nl == 0 or nl == 1 or nl == 5 or nl == 6) then
  print(nl)
elseif(nl == 2) then
  a = {6, 2, 4, 8}
  print(a[mnum % 4 + 1])
elseif(nl == 3) then
  a = {1, 3, 9, 7}
  print(a[mnum % 4 + 1])
elseif(nl == 4) then
  print(mnum % 2 == 0 and 6 or 4)
elseif(nl == 7) then
  a = {1, 7, 9, 3}
  print(a[mnum % 4 + 1])
elseif(nl == 8) then
  a = {6, 8, 4, 2}
  print(a[mnum % 4 + 1])
else
  print(mnum % 2 == 0 and 1 or 9)
end
0