結果
問題 | No.49 算数の宿題 |
ユーザー | karrym_ |
提出日時 | 2014-10-23 23:30:26 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 366 bytes |
コンパイル時間 | 1,565 ms |
コンパイル使用メモリ | 167,696 KB |
実行使用メモリ | 7,172 KB |
最終ジャッジ日時 | 2023-08-24 17:23:05 |
合計ジャッジ時間 | 2,421 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,012 KB |
testcase_01 | AC | 2 ms
6,932 KB |
testcase_02 | AC | 2 ms
6,932 KB |
testcase_03 | AC | 2 ms
7,068 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 2 ms
6,972 KB |
testcase_07 | WA | - |
testcase_08 | AC | 2 ms
7,080 KB |
testcase_09 | 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 ) Main.hs:6:1: warning: [GHC-94817] [-Wtabs] Tab character found here, and in 12 further locations. Suggested fix: Please use spaces instead. | 6 | <|> exec '*' (+) | ^^^^^^^^ [2 of 2] Linking a.out
ソースコード
import Data.List import Control.Applicative eval :: String -> Maybe Int eval str = exec '+' (*) <|> exec '*' (+) <|> (return $ read str) where exec :: Char -> (Int -> Int -> Int) -> Maybe Int exec ch op = do n <- elemIndex ch str let (a, ch:b) = splitAt n str op <$> eval a <*> eval b main = fmap eval getLine >>= \(Just n) -> print n