x^2 + S(x)*x - n=0 where n can be till 10^8 interger . and s(x) is the sum of the digits of the x integer. we have to print the value of x for which this equation holds otherwise print -1. my answer is taking too much time with brute force. can anyone give any hint ?
Jump to Post
Hmm how do you brute force it currently? Some optimizations (but it's still brute forcing) would be to:
don't count the amount of digits per attempted number (or maybe not at all) instead start at i=10, j = 1 where you multiply i by 10 everytime your number hits i …