if I see it right your restoring algorithm
is computing integer division a/b
...
integer n-th root is computing a^(1/b)
the usual ways are either using log,exp
approach and round/truncate or binary search along with power a^b
for more info see:
Yes you can use division instead but unless I miss something it would be very inefficient.
simply binary search a / (answer^(b-1)) >= answer
the answer limit will be 2^(log2(a)/b)
so just find the min power of 2 which is >= a and use b times less bits ...
you could probably optimize this by ignore answers that are multiple of already rejected answer and or use some modular arithemic trick related to GCD or something where binomal expansion might come be handy... My intuition tells me you would end up with prime decomposition and just check if the exponents are all b
or the same multiple of b
...
So in my opinion its possible but its too much work with most likely much worse performance than simple approaches mentioned before unless I missing something ...