結果

問題 No.167 N^M mod 10
ユーザー むらためむらため
提出日時 2019-01-18 19:30:52
言語 Nim
(2.0.2)
結果
RE  
実行時間 -
コード長 1,079 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 66,588 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:14:55
合計ジャッジ時間 4,088 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 RE -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 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 : char
  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