結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー Nekosan
提出日時 2015-08-11 13:05:42
言語 Haskell
(9.10.1)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 6,156 ms
コンパイル使用メモリ 173,896 KB
実行使用メモリ 25,220 KB
平均クエリ数 3.70
最終ジャッジ日時 2024-07-16 21:10:15
合計ジャッジ時間 9,676 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 (-1)
    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