結果
| 問題 |
No.358 も~っと!門松列
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2016-05-05 15:55:02 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,299 bytes |
| コンパイル時間 | 9,659 ms |
| コンパイル使用メモリ | 180,796 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-05 09:42:40 |
| 合計ジャッジ時間 | 9,546 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 )
Main.hs:22:5: warning: [GHC-53633] [-Woverlapping-patterns]
Pattern match is redundant
In an equation for ‘solve’: solve a b c | isKadomatsu a b c = ...
|
22 | | isKadomatsu a b c = -1
| ^^^^^^^^^^^^^^^^^
[2 of 2] Linking a.out
ソースコード
import qualified Data.ByteString.Char8 as C
import Data.Char
import Data.Array.IO
main :: IO ()
main = do
ss <- C.getLine
let (a, r1) = nextInt ss
let (b, r2) = nextInt r1
let (c, r3) = nextInt r2
printans $ solve a b c
isKadomatsu :: Int -> Int -> Int -> Bool
isKadomatsu a b c
| a < b && b > c && a /= c = True
| a > b && b < c && a /= c = True
| otherwise = False
solve :: Int -> Int -> Int -> Int
solve a b c
| isKadomatsu a b c = -1
| isKadomatsu a b c = -1
| otherwise = solve2 a b c
solve2 :: Int -> Int -> Int -> Int
solve2 a b c = solve3 a b c m
where m = max a $ max b c
solve3 :: Int -> Int -> Int -> Int -> Int
solve3 a b c m
| m < 1 = 0
| isKadomatsu a' b' c' = x + 1
| otherwise = x
where a' = mod a m
b' = mod b m
c' = mod c m
x = solve3 a b c (m - 1)
printans :: Int -> IO ()
printans n
| n < 0 = putStrLn "INF"
| otherwise = print n
nextInt :: C.ByteString -> (Int, C.ByteString)
nextInt ss
| isDigit x = nextInt2 0 ss
| otherwise = nextInt $ C.tail ss
where x = C.head ss
nextInt2 :: Int -> C.ByteString -> (Int, C.ByteString)
nextInt2 n ss
| C.null ss = (n, ss)
| isDigit y = nextInt2 (n * 10 + (digitToInt y)) ys
| otherwise = (n, ys)
where y = C.head ss
ys = C.tail ss
alpha_virginis