結果
問題 | No.358 も~っと!門松列 |
ユーザー |
![]() |
提出日時 | 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
ソースコード
importqualifiedData.ByteString.CharasCimportData.CharimportData.Array.IOmain::IO()main = doss <- C.getLinelet (a, r1) = nextInt sslet (b, r2) = nextInt r1let (c, r3) = nextInt r2printans $ solve a b cisKadomatsu::Int->Int->Int->BoolisKadomatsu a b c| a < b && b > c && a /= c = True| a > b && b < c && a /= c = True| otherwise = Falsesolve::Int->Int->Int->Intsolve a b c| isKadomatsu a b c = -1| isKadomatsu a b c = -1| otherwise = solve2 a b csolve2::Int->Int->Int->Intsolve2 a b c = solve3 a b c mwhere m = max a $ max b csolve3::Int->Int->Int->Int->Intsolve3 a b c m| m < 1 = 0| isKadomatsu a' b' c' = x + 1| otherwise = xwhere a' = mod a mb' = mod b mc' = mod c mx = solve3 a b c (m - 1)printans::Int->IO()printans n| n < 0 = putStrLn "INF"| otherwise = print nnextInt::CByteString->IntCByteStringnextInt ss| isDigit x = nextInt2 0 ss| otherwise = nextInt $ C.tail sswhere x = C.head ssnextInt2::Int->CByteString->IntCByteStringnextInt2 n ss| C.null ss = (n, ss)| isDigit y = nextInt2 (n * 10 + (digitToInt y)) ys| otherwise = (n, ys)where y = C.head ssys = C.tail ss