Nice and Sunsan play the game of multiplication by ultiplying an integer p by one of the number2 2 to 9.Nic always starts with p = 1, does his multiplication.Then Susan multiplies the number, then Nic and so on. Before a game starts, they draw an integer 1<= n <= 4,294,967,295 and the winner is who first reaches p>=n.
Inuput: Each line of input contains one integer number n and ends while n = 0.
Output: For each line of input output one line either
Nic wins.
or
Susan wins.
Assume that both of them play perfectly.
Sample Input:
162
17
34012226
0
Output for the Sample Input:
Nic wins.
Susan wins.
Nic wins.
1
/**//*Sulution: Nic(1st) wins over [1, 9], Susan(2nd) wins over [10, 18], Nic(1st) wins over [19, 162], Susan(2nd) wins over [163, 344], think a little and easy know why, then wo can get that 9 * 2 -> 18 * 9 -> 162 ->344……
2*/
3
4
#include<iostream>
5
6
using namespace std;
7
8
int main()
9

{
10
int n, a, b;
11
bool isFirWin;
12
13
cin >> n;
14
while(n != 0)
15
{
16
a = 1;
17
b = 9;
18
isFirWin = true;
19
20
do
21
{
22
if(a <= n && n <= b) break;
23
else
24
{
25
a = b + 1;
26
27
if(isFirWin)
28
{
29
b = b * 2;
30
isFirWin = false;
31
}
32
else
33
{
34
b = b * 9;
35
isFirWin = true;
36
}
37
}
38
}while(1);
39
40
if(isFirWin)
41
cout << "Nic wins.\n";
42
else
43
cout << "Susan wins.\n";
44
45
cin >> n;
46
}
47
48
return 0;
49
}