Code: Select all
1
4
27
256
3125
46656
Where is the mistake in my reasoning?
Moderator: Board moderators
Code: Select all
1
4
27
256
3125
46656
Have fun~For each test case, print on a single line the value of N if a unique N satisfying N^N=S can be found. Otherwise, print -1 in the corresponding line, showing that I made a mistake in calculating.
I'd like to see an explanation for 3225 whats the other solution other than 5 so that we get -1 as the result ???Abednego wrote:Could anyone explain this problem to me please? What is meant by an "error in at most one single digit"? The first few values of n^n areSo I understand the first sample input. If the input is 3, then we are unsure whether the correct number is 1 or 4; therefore, the answer is -1. But I don't understand why the answer to input 4 is 2 and why the answer to input 3225 is -1. 4 differs in at most one digit from both 1 and 4, so the answer should be -1 (uncertain), and 3225 differs in at most one digit from 3125, so the answer should be 5.Code: Select all
1 4 27 256 3125 46656
Where is the mistake in my reasoning?
Since there is no terribly wrong result for N^N, you don't really need to evaluate the value of N^N.crip121 wrote:i am unsuccessfully trying to solve this problem.... here's my algo
1. generate digit[x] -> number of digit(s) in x^x ( using log )
2. take input and binary search in digit[] to get a approx
3. use fast exponentiation to evaluate x^x
4. check whether calculated x^x is equal as given input string and output accordingly
im getting TLE... can anyone tell me is my approach is right or there is another better solution that im missing....