結果

問題 No.167 N^M mod 10
ユーザー むらためむらため
提出日時 2019-01-18 19:31:49
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,078 bytes
コンパイル時間 4,135 ms
コンパイル使用メモリ 60,800 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 00:26:18
合計ジャッジ時間 5,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 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 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 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 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord

proc scanN(): int =
  var pre : char
  while true:
    var k = getchar_unlocked()
    if k < '0' : break
    pre = k
  return pre.ord - '0'.ord

let n = scanN()

if n in [0,1,5,6]:
  if getchar_unlocked() == '0': echo 1
  else: echo n
  quit 0

var c = getchar_unlocked()
if c == '0': quit "1", 0
if n in [4,9]:
  while true:
    let k = getchar_unlocked()
    if k < '0' :
      let last = (c.ord - '0'.ord) mod 2
      if n == 4: echo [6,4][last]
      elif n == 9: echo [1,9][last]
      quit 0
    c = k
else:
  var d = '0'
  while true:
    let k = getchar_unlocked()
    if k < '0' :
      let last = ((d.ord - '0'.ord) * 10 + (c.ord - '0'.ord)) mod 4
      if n == 2: echo [6,2,4,8][last]
      elif n == 3: echo [1,3,9,7][last]
      elif n == 7: echo [1,7,9,3][last]
      elif n == 8: echo [6,8,4,2][last]
      quit 0
    d = c
    c = k
0