10275 - Guess the Number!

All about problems in Volume 102. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

10275 - Guess the Number!

Post by Abednego »

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 are

Code: Select all

1
4
27
256
3125
46656
So 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.

Where is the mistake in my reasoning?
If only I had as much free time as I did in college...
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

Hi,

I guess you should have a look at the problem description again:
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.
Have fun~
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
crip121
New poster
Posts: 29
Joined: Tue Jul 08, 2008 9:04 pm

Re: 10275 - Guess the Number!

Post by crip121 »

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.... :(
KRUNCH
New poster
Posts: 8
Joined: Sun May 18, 2008 1:03 pm

Re: 10275 - Guess the Number!

Post by KRUNCH »

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 are

Code: Select all

1
4
27
256
3125
46656
So 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.

Where is the mistake in my reasoning?
I'd like to see an explanation for 3225 whats the other solution other than 5 so that we get -1 as the result ???
athena lin
New poster
Posts: 1
Joined: Fri Mar 04, 2011 11:47 am

Re: 10275 - Guess the Number!

Post by athena lin »

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.... :(
Since there is no terribly wrong result for N^N, you don't really need to evaluate the value of N^N.
Just try to divide S by N.
Post Reply

Return to “Volume 102 (10200-10299)”