main :: IO () main = interact $ show . solve . map read . words solve :: [Int] -> Int solve [works, deadline] = foldl (\a x -> a - (a `div` ((deadline - x + 1) ^ 2))) works [1 .. (deadline - 1)]