[Cpp]
/** Game question .. This kind of question is characterized by: it is very easy to think of after thinking of the method, unexpected
* You can't do it .. I first tried to list all the results, and found that the data volume was too large.
* It didn't work. Later I looked at the game and suddenly burst into a flash, thinking that I only wanted to consider the current
* Step, set the total number to 1 ~ When count is used, the first player wins or loses. The equation is:
* If (I-a [I] = 0 |! Num [I-a [I] (I-a [I]> 0) wins first
* It means that the opponent will lose after moving or moving once.
*/
# Include <cstdio>
# Include <cstring>
Using namespace std;
# Define MAX 12
# Deprecision MAXC 121
Int a [MAX];
Int num [MAXC];
Void move_stones (int count, int type ){
For (int I = 1; I <= count; I ++ ){
For (int j = 0; j <type; j ++ ){
If (I-a [j]> 0 &&! Num [I-a [j]) {
Num [I] = 1;
Break;
} Else if (I-a [j] = 0 ){
Num [I] = 1;
Break;
}
}
}
If (num [count])
Printf ("Stan wins \ n ");
Else
Printf ("Ollie wins \ n ");
}
Int main (int argc, char const * argv [])
{
# Ifndef ONLINE_JUDGE
Freopen ("test. in", "r", stdin );
# Endif
Int count, type;
While (~ Scanf ("% d", & count )){
Memset (num, 0, sizeof (num ));
Scanf ("% d", & type );
For (int I = 0; I <type; I ++)
Scanf ("% d", & a [I]);
Move_stones (count, type );
}
Return 0;
}