A Multiplication Game
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7442 Accepted Submission(s): 4213
Problem 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
162
17
34012226
17
34012226
Sample Output
Stan wins.
Ollie wins.
Stan wins.
Ollie wins.
Stan wins.
题意:给出一个n,要求每人每次在p的基础上乘2-9之间的数,第一个使结果大于等于n的人获胜,p初始为1
题解:巴什博弈的变形,先手想赢的话就应该要多乘2,要让后手输就多乘9. emmmm 没毛病
#include<bits/stdc++.h>
using namespace std;
int main() {
long long n;
while(~scanf("%lld",&n))
{
long long sum=;
for(int i=;i++;)
{
if(sum>=n)
{
sum=i;break;
}
if(i%)
{
sum*=;
}
else
{
sum*=;
} } if(sum%)printf("Stan wins.\n");
else printf("Ollie wins.\n");
}
return ;
}