• + 0 comments

    Brute force solution... Fails on the timed case :(

    import Data.List
    
    solve x n = length . filter ((x ==) . sum) . subsequences $ ls
        where ls = [p ^ n | p <- [1 .. round $ fromIntegral x ** (1 / fromIntegral n)]]
        
    main = do
        [x,n] <- getContents >>= (\s -> return . map read $ lines s)
        print $ solve x n