main :: IO () main = interact $ show . solve . map read . words myFloor :: Int -> Int -> Int myFloor m n = floor $ (fromIntegral m) / (fromIntegral n) solve :: [Int] -> Int solve [works, deadline] = yaruki deadline where yaruki :: Int -> Int yaruki 0 = 0 yaruki x = myFloor (works - sum [yaruki (k - 1) | k <- [1..x]]) ((deadline - x + 1) ^ 2)