結果

問題 No.49 算数の宿題
ユーザー karrym_
提出日時 2014-10-23 23:30:26
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 366 bytes
コンパイル時間 5,767 ms
コンパイル使用メモリ 169,216 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 01:42:10
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/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

ソースコード

diff #

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
0