結果

問題 No.167 N^M mod 10
ユーザー 佐藤淳平佐藤淳平
提出日時 2019-09-09 20:09:32
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 1,169 bytes
コンパイル時間 4,518 ms
コンパイル使用メモリ 163,000 KB
実行使用メモリ 10,944 KB
最終ジャッジ日時 2023-09-10 23:41:38
合計ジャッジ時間 2,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,720 KB
testcase_01 AC 3 ms
6,632 KB
testcase_02 AC 7 ms
10,868 KB
testcase_03 AC 8 ms
10,872 KB
testcase_04 AC 6 ms
10,076 KB
testcase_05 AC 3 ms
6,748 KB
testcase_06 AC 3 ms
6,980 KB
testcase_07 AC 3 ms
6,908 KB
testcase_08 AC 3 ms
6,984 KB
testcase_09 AC 3 ms
6,620 KB
testcase_10 AC 2 ms
6,908 KB
testcase_11 AC 2 ms
7,052 KB
testcase_12 AC 2 ms
6,924 KB
testcase_13 AC 3 ms
6,964 KB
testcase_14 WA -
testcase_15 AC 3 ms
6,664 KB
testcase_16 AC 2 ms
6,724 KB
testcase_17 AC 3 ms
6,716 KB
testcase_18 AC 2 ms
7,020 KB
testcase_19 AC 2 ms
6,980 KB
testcase_20 AC 3 ms
7,048 KB
testcase_21 AC 3 ms
6,720 KB
testcase_22 AC 7 ms
10,852 KB
testcase_23 AC 7 ms
10,924 KB
testcase_24 AC 6 ms
9,976 KB
testcase_25 AC 7 ms
10,944 KB
testcase_26 AC 5 ms
8,372 KB
testcase_27 AC 7 ms
10,928 KB
testcase_28 AC 6 ms
10,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 (digitToInt)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = interact $ show . solve . words

solve :: [String] -> Int
solve [s, t]
    | n == 0   = 0
    | t == "0" = 1
    | n == 1   = 1
    | n == 2   = if i `mod` 4 == 1 then 2 else if i `mod` 4 == 2 then 4 else if i `mod` 4 == 3 then 8 else 6
    | n == 3   = if i `mod` 4 == 1 then 3 else if i `mod` 4 == 2 then 9 else if i `mod` 4 == 3 then 7 else 1
    | n == 4   = if m `mod` 2 == 0 then 6 else 4
    | n == 5   = 5
    | n == 6   = 6
    | n == 7   = if i `mod` 4 == 1 then 7 else if i `mod` 4 == 2 then 9 else if i `mod` 4 == 3 then 3 else 1
    | n == 8   = if i `mod` 4 == 1 then 8 else if i `mod` 4 == 2 then 4 else if i `mod` 4 == 3 then 2 else 6
    | n == 9   = if m `mod` 2 == 0 then 1 else 9
    | otherwise = error ""
    where
        n = if (length s) <= 1 then (read :: String -> Int) s else digitToInt $ last s
        m = if (length t) <= 1 then (read :: String -> Int) t else digitToInt $ last t
        i = if (length t) <= 1 then (read :: String -> Int) t else (read :: String -> Int) ([last $ init t] ++ [last t])
0