結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー Nekosan
提出日時 2015-08-11 12:57:38
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 4,699 ms
コンパイル使用メモリ 173,824 KB
実行使用メモリ 25,856 KB
平均クエリ数 3.27
最終ジャッジ日時 2024-07-16 05:40:30
合計ジャッジ時間 8,349 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 4 RE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

import System.IO

main = do
    line <- getLine
    let n = read $ (words line) !! 0 :: Int
        k = read $ (words line) !! 1 :: Int
        ans = show $ ai n k 0
    putStrLn ans
    hFlush stdout
    game n k


game :: Int -> Int -> IO ()
game n k = do
    opp <- getLine
    let s = read opp :: Int
    if s < n
        then do
            let ans = show $ ai n k s
            putStrLn ans
            hFlush stdout
            game n k
        else
            return ()


ai :: Int -> Int -> Int -> Int
ai n k s = last ansList
    where   ansList = takeWhile (>s) [n - x * (k + 1) - 1 | x <- [0..]]
0