結果

問題 No.358 も~っと!門松列
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-04-19 21:52:33
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 147,840 KB
最終ジャッジ日時 2024-04-27 02:20:06
合計ジャッジ時間 562 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
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:4:1: error: [GHC-07626]
    Parse error in pattern: isKadoSeq In a function binding for the ‘@’ operator.
                            Perhaps you meant an as-pattern, which must not be surrounded by whitespace
  |
4 | isKadoSeq xs @ (a : b : c : []) = c1 && c2
  | ^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative ((<$>))

isKadoSeq :: (Integral a, Ord a) => [a] -> Bool
isKadoSeq xs @ (a : b : c : []) = c1 && c2
    where
        c1 = a /= b && b /= c && c /= a
        c2 = b == (maximum xs) || b == (minimum xs)
isKadoSeq _ = False

countP :: (Integral a, Ord a) => [a] -> Maybe a
countP xs
    | isKadoSeq xs = Nothing
    | otherwise = Just $ sum [1 | p <- [1 .. maximum xs], isKadoSeq $ map (`mod` p) xs]

main :: IO ()
main = do
    xs <- map read . words <$> getLine
    case countP xs of
        Just n -> print n
        Nothing -> putStrLn "INF"
0