結果

問題 No.167 N^M mod 10
ユーザー aimyaimy
提出日時 2017-04-27 12:16:52
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 369 bytes
コンパイル時間 7,521 ms
コンパイル使用メモリ 164,220 KB
実行使用メモリ 11,712 KB
最終ジャッジ日時 2023-10-11 16:02:11
合計ジャッジ時間 5,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,024 KB
testcase_01 AC 2 ms
6,992 KB
testcase_02 AC 12 ms
11,656 KB
testcase_03 AC 8 ms
11,712 KB
testcase_04 AC 12 ms
11,636 KB
testcase_05 AC 2 ms
6,884 KB
testcase_06 AC 3 ms
6,900 KB
testcase_07 AC 3 ms
6,936 KB
testcase_08 AC 2 ms
6,892 KB
testcase_09 AC 3 ms
6,976 KB
testcase_10 AC 3 ms
6,884 KB
testcase_11 AC 2 ms
6,860 KB
testcase_12 AC 2 ms
6,936 KB
testcase_13 AC 2 ms
6,900 KB
testcase_14 AC 2 ms
6,868 KB
testcase_15 AC 3 ms
6,884 KB
testcase_16 WA -
testcase_17 AC 3 ms
6,952 KB
testcase_18 AC 3 ms
6,968 KB
testcase_19 AC 3 ms
7,028 KB
testcase_20 AC 3 ms
7,056 KB
testcase_21 AC 2 ms
7,028 KB
testcase_22 AC 12 ms
11,668 KB
testcase_23 AC 8 ms
11,592 KB
testcase_24 WA -
testcase_25 AC 8 ms
11,672 KB
testcase_26 AC 3 ms
7,260 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Char

main = do
 n <- digitToInt . last <$> getLine
 m <- readLn
 print (expn n m)

expn _ 0 = 1
expn 0 _ = 0
expn n 1 = n
expn 1 _ = 1
expn 2 m = [6,2,4,8] !! (mod m 4)
expn 3 m = [1,3,9,7] !! (mod m 4)
expn 4 m = [6,4] !! (mod m 2)
expn 5 m = 5
expn 6 m = 6
expn 7 m = [1,7,9,3] !! (mod m 4)
expn 8 m = [6,8,4,2] !! (mod m 4)
expn 9 m = [9,1] !! (mod m 2)
0