ZCMU-巴什博弈

来源:互联网 发布:理肤泉和雅漾喷雾 知乎 编辑:程序博客网 时间:2024/05/21 01:55

Problem E: Problem E: A multiplication game

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 46  Solved: 29
[Submit][Status][Web Board]

Description

Problem E: A multiplication game

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. Each line of input contains one integer number n. For each line of input output one line either

Stan wins.

or

Ollie wins.

assuming that both of them play perfectly.

Input

Output

Sample Input

162
17
34012226

Sample Output

Stan wins.
Ollie wins.
Stan wins.


【解析】
这道题巴什博奕论,意思就是找规律喽,我们发现如果输入的是2-9就是stan胜利,因为是stan选出手,如果是10-18
了,如果超过了18那就是小于等于162,那就是stan胜利了,因为18*9=162这样推着推着我们发现其实就是不断的除
18,如果最好得到小于等于9的数那就是stan胜利。2-9肯定是stan胜利,10-18肯定是online,19-162只要stan不傻
他都能胜利

#include<iostream>#include<string>#include<map>#include<cstring>#include<cstdio>using namespace std;double n;int main(){while(~scanf("%lf",&n)){    while(n>18)        n=n/18;    if(n>9)        printf("Ollie wins.\n");    else        printf("Stan wins.\n");}     return 0;}

0 0
原创粉丝点击