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_memo :: [Int] yaruki_memo = map yaruki [0..] yaruki :: Int -> Int yaruki 0 = 0 yaruki x = myFloor (works - (sum $ take x yaruki_memo)) ((deadline - x + 1) ^ 2)