A multiplication game
Time limit:1000 ms |
|
Memory limit:65536 K |
Total submissions:4108 |
|
Accepted:1981 |
Description
Stan and Ollie play the game of multiplication by multiplying an integer p by one of the numbers 2 to 9. stan always starts with p = 1, does his multiplication, then Ollie multiplies the number, then Stan and so on. before a game starts, they draw an integer 1 <n <4294967295 and the winner is who first reaches P> = n.
Input
Each line of input contains one integer number n.
Output
For each line of input output one line either
Stan wins.
Or
Ollie wins.
Assuming that both of them play perfectly.
Sample Input
1621734012226
Sample output
Stan wins. Ollie wins. Stan wins.
Source
Waterloo local 2001.09.22
/*
HDU 1517
Game questions;
Assume that two people play the game. Starting from 1, the number of players is multiplied in turn until the number of players exceeds a specified value.
Solution:
If the input is 2 ~ 9. Stan wins because he is a pioneer
If the input is 10 ~ 18, because Ollie is a postmaster, no matter what the first Stan ride is, Stan must be in 2 ~ Between 9,
If Stan is multiplied by 2, Ollie is multiplied by 9 to 18. If Stan is multiplied by 9,
Then, the number of Ollie multiplied by 1 can all exceed 10 ~ Any number in 18. Ollie wins
If the input is 19 ~ 162, so the range is the victory of Stan
If the input is 163 ~ 324. This is also the winning form of Ollie.
............
The winning state is symmetric !!!
If "we" first gives an example of getting less than 18 after N is Division 18
M, "we" can win, but both sides are very smart, so the victory is decided on N. If n is continuously divided
After 18, the number of M is less than 18. If 1 <m <= 9, the first hand wins, that is, Stan wins. If 9 <m <= 18
Then the latter wins.
*/
# Include < Stdio. h >
Int Main ()
{
Double N;
While (Scanf ( " % Lf " , & N) ! = EOF)
{
While (N > 18 ) N /= 18 ;
If (N <= 9 ) Printf ( " Stan wins. \ n " );
Else Printf ( " Ollie wins. \ n " );
}
Return 0 ;
}