結果

問題 No.305 鍵(2)
ユーザー ducktailducktail
提出日時 2018-08-08 16:39:48
言語 Haskell
(9.8.2)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 164,980 KB
実行使用メモリ 24,396 KB
平均クエリ数 43.54
最終ジャッジ日時 2023-09-24 01:52:33
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,216 KB
testcase_01 AC 28 ms
24,288 KB
testcase_02 AC 25 ms
23,664 KB
testcase_03 AC 25 ms
23,448 KB
testcase_04 AC 26 ms
23,652 KB
testcase_05 AC 30 ms
24,324 KB
testcase_06 AC 25 ms
23,928 KB
testcase_07 AC 27 ms
23,400 KB
testcase_08 AC 28 ms
23,520 KB
testcase_09 AC 28 ms
23,560 KB
testcase_10 AC 26 ms
24,396 KB
testcase_11 AC 25 ms
24,384 KB
testcase_12 AC 30 ms
23,612 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))
import Control.Monad (unless)
import System.IO (hFlush, stdout)

import Text.Printf

main :: IO ()
main = do
  printf "%010d\n" (0::Int)
  hFlush stdout
  [s,rslt] <- words <$> getLine
  unless (rslt == "unlocked") $ solve (read s) 0 1
    

solve :: Int -> Int -> Int -> IO ()
solve mtc ecn d = do
  let nn = ecn + d
  printf "%010d\n" nn
  hFlush stdout
  [s,rslt] <- words <$> getLine
  unless (rslt == "unlocked") $ do
    let nc = read s :: Int
    if nc > mtc then do
      solve nc nn (d * 10)
    else if nc < mtc then do
      solve mtc ecn (d * 10)
    else do
      solve mtc nn d
0