Game problem.
Test instructions: 2 people play the game, starting from 1, take the logarithm to multiply, until more than a specified value n.
Analysis:
1, if input 2 ~ 9, because Stan is the initiator, so Stan win
2, if the input 10~18, because Ollie is, regardless of the first time Stan is what, Stan must be between 2 ~ 9, if Stan Times 2, then Ollie multiplied by 9, to 18, if Stan multiplied by 9, then Ollie Times greater than 1 of the number can be more than 10 ~ Any number in the 18. Ollie win
3, if the input is 19 ~ 162, then this range is Stan's winning state
4, if the input is 163 ~ 324, this is another Ollie of the winning state
5, the winning state is symmetrical!!!
So the outcome of the decision on N, if N is constantly in addition to 18 after the number of less than 18 m, if the 1 Then the hand wins.
#include <iostream>using namespace Std;int main () {double N;while (cin>>n) {while (n>18) n/=18;if (n<=9 ) puts ("Stan wins."); Else puts ("Ollie wins.");} return 0;}
HDU ACM 1517 A multiplication Game