• + 0 comments

    f# solution

    open System
    
    let rec count b x n =
        match int (float b ** float n) with
        | bn when bn = x -> 1
        | bn when bn > x -> 0
        | bn -> (count (b + 1) (x - bn) n) + (count (b + 1) (x) n)
    
    [<EntryPoint>]
    let main _ =
        let x = Console.ReadLine() |> int
        let n = Console.ReadLine() |> int
    
        count 1 x n |> string |> Console.WriteLine
    
        0