You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
The Sums of Powers
You are viewing a single comment's thread. Return to all comments →
Brute force solution... Fails on the timed case :(