結果

問題 No.358 も~っと!門松列
ユーザー Leonardone
提出日時 2016-04-17 23:53:37
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 3,932 ms
コンパイル使用メモリ 171,904 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 11:06:44
合計ジャッジ時間 4,673 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

-- Try yukicoder
-- author: Leonardone @ NEETSDKASU


isKadomatsuRetsu :: [Int] -> Bool
isKadomatsuRetsu [a1, a2, a3] = a1 /= a3 && (a2 == minval || a2 == maxval)
    where
        a123 = [a1, a2, a3]
        minval = minimum a123
        maxval = maximum a123



main = putStrLn . solve . map read . words =<< getLine

solve [a1, a2, a3] = if isKadomatsuRetsu a123 then "INF" else show count
    where
        a123 = [a1, a2, a3]
        maxval = maximum a123
        modKadomatsu p = map (`mod` p) a123
        count = sum $ map (\p -> if isKadomatsuRetsu $ modKadomatsu p then 1 else 0 ) [1 .. maxval]
        
0