結果
問題 |
No.167 N^M mod 10
|
ユーザー |
|
提出日時 | 2018-06-22 15:33:51 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 752 bytes |
コンパイル時間 | 3,579 ms |
コンパイル使用メモリ | 180,576 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 17:58:54 |
合計ジャッジ時間 | 4,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 6 |
コンパイルメッセージ
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
ソースコード
import Control.Applicative ((<$>), (<*>)) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B main :: IO () main = solve <$> (cut 1 <$> B.getLine) <*> (cut 2 <$> B.getLine) >>= print solve :: Int -> Int -> Int solve _ 0 = 1 solve n m = ls !! ((m-1) `mod` x) where tbl = [(1, [0]), (1, [1]), (4, [2, 4, 8, 6]), (4, [3, 9, 7, 1]), (2,[4, 6]), (1, [5]), (1, [6]), (4, [7, 9, 3, 1]), (4, [8, 4, 2, 6]), (2, [9, 1])] (x, ls) = tbl !! n readi :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> a readi f s = let Just (n, _) = f s in n cut :: Int -> ByteString -> Int cut n bs = readi B.readInt (if l > n then B.drop (l-n) bs else bs) where l = B.length bs