結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 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,strutilsproc ctoi(c : char): int =return ord(c) - ord('0')proc stringmod(s : string, m : int) : int =varans = 0for i in 0..s.high:ans *= 10ans += s[i].ctoians = ans mod mreturn ansvarN = stdin.readlineM = stdin.readlinet : intm = N[^1].ctoie = m * mif M == "0":echo 1else:if m == 0:echo 0elif m == 1:echo 1elif m == 2:case stringmod(M, 4)of 0:echo 6of 1:echo 2of 2:echo 4of 3:echo 8else:discardelif m == 3:case stringmod(M, 4)of 0:echo 1of 1:echo 3of 2:echo 9of 3:echo 7else:discardelif m == 4:case stringmod(M, 2)of 0:echo 6of 1:echo 4else:discardelif m == 5:echo 5elif m == 6:echo 6elif m == 7:case stringmod(M, 4)of 0:echo 1of 1:echo 7of 2:echo 9of 3:echo 3else:discardelif m == 8:case stringmod(M, 4)of 0:echo 6of 1:echo 8of 2:echo 4of 3:echo 2else:discardelif m == 9:case stringmod(M, 2)of 0:echo 1of 1:echo 9else:discard