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