結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,976 KB
testcase_01 AC 2 ms
6,956 KB
testcase_02 AC 7 ms
11,612 KB
testcase_03 AC 7 ms
11,640 KB
testcase_04 AC 12 ms
11,640 KB
testcase_05 AC 2 ms
7,104 KB
testcase_06 AC 3 ms
6,920 KB
testcase_07 AC 2 ms
6,872 KB
testcase_08 AC 2 ms
6,896 KB
testcase_09 AC 3 ms
7,004 KB
testcase_10 AC 3 ms
6,848 KB
testcase_11 AC 2 ms
6,880 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,948 KB
testcase_14 AC 3 ms
6,852 KB
testcase_15 AC 3 ms
6,864 KB
testcase_16 AC 2 ms
7,100 KB
testcase_17 AC 3 ms
6,968 KB
testcase_18 AC 3 ms
6,996 KB
testcase_19 AC 3 ms
6,980 KB
testcase_20 AC 3 ms
6,996 KB
testcase_21 AC 2 ms
7,092 KB
testcase_22 AC 7 ms
11,636 KB
testcase_23 AC 7 ms
11,676 KB
testcase_24 AC 12 ms
11,604 KB
testcase_25 AC 12 ms
11,628 KB
testcase_26 AC 3 ms
7,232 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 = [1,9] !! (mod m 2)
0