結果
| 問題 |
No.250 atetubouのzetubou
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-06-07 22:45:42 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 1,695 ms / 5,000 ms |
| コード長 | 951 bytes |
| コンパイル時間 | 4,574 ms |
| コンパイル使用メモリ | 191,232 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-10-08 22:06:38 |
| 合計ジャッジ時間 | 29,974 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
コンパイルメッセージ
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
ソースコード
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy.Char8 as LC
import qualified Data.ByteString.Char8 as SC
import Data.Maybe (fromJust)
data Status = AC | ZETUBOU deriving (Enum, Show)
type Query a = (a, a, a)
binom :: Integral a => a -> a -> a
binom n k = product [k + 1 .. n] `div` product [1 .. n - k]
querify :: [a] -> Query a
querify [x, y, z] = (x, y, z)
querify _ = error "the length of the list must be three"
judge :: Integral a => Query a -> Status
judge (d, x, t)
| binom (x + d - 1) x <= t = AC
| otherwise = ZETUBOU
unsafeReadInteger :: LC.ByteString -> Integer
unsafeReadInteger = fst . fromJust . LC.readInteger
showStatus :: Status -> SC.ByteString
showStatus AC = "AC"
showStatus ZETUBOU = "ZETUBOU"
main :: IO ()
main = do
_ <- SC.getLine
SC.putStr . SC.unlines .
fmap (showStatus . judge . querify . fmap unsafeReadInteger . LC.words) .
LC.lines =<< LC.getContents
はむ吉🐹