-- Try yukicoder -- author: Leonardone @ NEETSDKASU import System.IO (hFlush, stdout) comm s = do putStrLn s hFlush stdout getLine return () main = do n <- readLn s <- getLine mapM_ comm $ play n s -- (名前,所有数,現在生産性,強化回数,次回購入価格,次回強化価格) items = [ ("click", 1, 1, 0, 0, 15) , ("hand", 0, 1, 0, 150, 1500) , ("lily", 0, 10, 0, 2000, 20000) , ("factory", 0, 120, 0, 30000, 300000) , ("casino", 0, 2000, 0, 600000, 6000000) , ("grimoire", 0, 25000, 0, 10000000, 100000000) ] command (cmd, _, _, _, _) = cmd product (_, prd, _, _, _) = prd updated (_, _, upd, _, _) = upd buyPrice (_, _, _, buy, _) = buy updPrice (_, _, _, _, upc) = upc play n s = game n s items 0 0 False game _ [] _ _ _ _= [] game turn es@(s:ss) items money fever sale = cmd : game (turn-1) ss items2 money2 fever2 sale2 where (cmd, items2, money1) = compute es items money fever sale money2 = money1 + calcBonus s money1 fever2 = updateFever s fever sale2 = isSale s calcBonus s money | s == 'B' = (money + 99) `div` 100 | otherwise = 0 updateFever s fever | s == 'F' = 20 | fever > 0 = fever - 1 | otherwise = 0 isSale = (== 'S') compute es items money fever sale = ("click", items, money)