結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2019-09-09 20:10:27 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 6 ms / 1,000 ms |
コード長 | 1,169 bytes |
コンパイル時間 | 4,796 ms |
コンパイル使用メモリ | 170,496 KB |
実行使用メモリ | 7,808 KB |
最終ジャッジ日時 | 2024-11-14 21:38:57 |
合計ジャッジ時間 | 5,856 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
importData.ChardigitToIntimportData.ByteString.CharByteStringimportqualifiedData.ByteString.CharasBmain::IO()main = interact $ show . solve . wordssolve::String->Intsolve [s, t]| t == "0" = 1| n == 0 = 0| 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 ""wheren = if (length s) <= 1 then (read :: String -> Int) s else digitToInt $ last sm = if (length t) <= 1 then (read :: String -> Int) t else digitToInt $ last ti = if (length t) <= 1 then (read :: String -> Int) t else (read :: String -> Int) ([last $ init t] ++ [last t])