// A multiplication game (multiplication game) // PC/Ultraviolet IDs: 110505/847, popularity: A, success rate: high level: 3 // verdict: accepted // submission date: 2011-05-29 // UV Run Time: 0.012 S // copyright (c) 2011, Qiu. Metaphysis # Yeah dot net // assume that the final number is 162. To prevent the other party from getting a number greater than or equal to 162, one Party should try to make the number not greater than 162 // 9 = 18. If the number is greater than or equal to 18, the other party can multiply the number by 9 to be greater than or equal to 162, one Party should try to multiply the number // to get a number greater than or equal to 9, because in this way, no matter which multiplier is selected by the other party, the product will eventually be greater than or equal to 18, because 9 // 9 = 1, that is, whoever takes the ride first will win. // For the given number N, if Stan reaches the number n first, it is a victory and returns to the previous step. If Stan reaches N/9 first, // fails, continue to the previous step. If Stan reaches N/9/2 first, win the game and use recursion to solve the problem. # Include <iostream> # include <cmath> using namespace STD; void ones (INT number, bool win) {If (number <= 9 & Win) {cout <"Stan wins. "<Endl; return;} If (number <= 2 &&! Win) {cout <"Ollie wins." <Endl; return;} If (WIN) ones (Ceil (number/9.0 ),! Win); elseones (Ceil (number/2.0 ),! Win);} int main (int ac, char * AV []) {int number; while (CIN> Number) ones (number, true); Return 0 ;}