結果
| 問題 |
No.358 も~っと!門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-18 00:00:12 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 3,068 ms |
| コンパイル使用メモリ | 169,472 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-04 11:09:17 |
| 合計ジャッジ時間 | 3,927 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
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
ソースコード
-- Try yukicoder
-- author: Leonardone @ NEETSDKASU
isKadomatsuRetsu :: [Int] -> Bool
isKadomatsuRetsu [a1, a2, a3] = a1 /= a3 && (isMinA2 || isMaxA2)
where
isMinA2 = a2 < a1 && a2 < a3
isMaxA2 = a2 > a1 && a2 > a3
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
counter p = if isKadomatsuRetsu $ modKadomatsu p then 1 else 0
count = sum $ map counter [1 .. maxval]