結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-10-19 21:40:45 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,755 bytes |
| コンパイル時間 | 3,340 ms |
| コンパイル使用メモリ | 64,988 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-22 01:43:17 |
| 合計ジャッジ時間 | 4,279 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
ソースコード
import sequtils,strutils
proc ctoi(c : char): int =
return ord(c) - ord('0')
proc stringmod(s : string, m : int) : int =
var
ans = 0
for i in 0..s.high:
ans *= 10
ans += s[i].ctoi
ans = ans mod m
return ans
var
N = stdin.readline
M = stdin.readline
t : int
m = N[^1].ctoi
e = m * m
if M == "0":
echo 1
else:
if m == 0:
echo 0
elif m == 1:
echo 1
elif m == 2:
case stringmod(M, 4)
of 0:
echo 6
of 1:
echo 2
of 2:
echo 4
of 3:
echo 8
else:
discard
elif m == 3:
case stringmod(M, 4)
of 0:
echo 1
of 1:
echo 3
of 2:
echo 9
of 3:
echo 7
else:
discard
elif m == 4:
case stringmod(M, 2)
of 0:
echo 6
of 1:
echo 4
else:
discard
elif m == 5:
echo 5
elif m == 6:
echo 6
elif m == 7:
case stringmod(M, 4)
of 0:
echo 1
of 1:
echo 7
of 2:
echo 9
of 3:
echo 3
else:
discard
elif m == 8:
case stringmod(M, 4)
of 0:
echo 6
of 1:
echo 8
of 2:
echo 4
of 3:
echo 2
else:
discard
elif m == 9:
case stringmod(M, 2)
of 0:
echo 1
of 1:
echo 9
else:
discard
6soukiti29