結果

問題 No.167 N^M mod 10
ユーザー aimyaimy
提出日時 2017-04-27 12:37:03
言語 Haskell
(9.8.2)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 474 bytes
コンパイル時間 8,346 ms
コンパイル使用メモリ 162,344 KB
実行使用メモリ 9,652 KB
最終ジャッジ日時 2023-10-22 00:17:02
合計ジャッジ時間 5,035 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,200 KB
testcase_01 AC 3 ms
5,200 KB
testcase_02 AC 7 ms
9,648 KB
testcase_03 AC 7 ms
9,648 KB
testcase_04 AC 7 ms
9,648 KB
testcase_05 AC 3 ms
5,200 KB
testcase_06 AC 2 ms
5,196 KB
testcase_07 AC 3 ms
5,132 KB
testcase_08 AC 2 ms
5,196 KB
testcase_09 AC 2 ms
5,196 KB
testcase_10 AC 3 ms
5,196 KB
testcase_11 AC 2 ms
5,196 KB
testcase_12 AC 3 ms
5,132 KB
testcase_13 AC 3 ms
5,196 KB
testcase_14 AC 2 ms
5,132 KB
testcase_15 AC 2 ms
5,196 KB
testcase_16 AC 3 ms
5,196 KB
testcase_17 AC 3 ms
5,200 KB
testcase_18 AC 3 ms
5,200 KB
testcase_19 AC 2 ms
5,200 KB
testcase_20 AC 3 ms
5,332 KB
testcase_21 AC 2 ms
5,344 KB
testcase_22 AC 7 ms
9,648 KB
testcase_23 AC 6 ms
9,648 KB
testcase_24 AC 7 ms
9,652 KB
testcase_25 AC 6 ms
9,648 KB
testcase_26 AC 3 ms
6,084 KB
testcase_27 AC 7 ms
9,588 KB
testcase_28 AC 7 ms
9,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/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 :: IO Integer
 print (expn n m)

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