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

Sample Output

Stan wins.
Ollie wins.
Stan wins.

Source

University of Waterloo Local Contest 2001.09.22


思路

跟巴什博奕不同的是,这里是乘法,但是思路差不多

可取区间在\([2,9]\),显然如果这是Stan的必胜段,而\([10,18]\)是Stan的必败段,这样一次博弈就完成了,后面的状态要得出来也可以,\([19,162]\)为Stan的必胜段,更后面的情况可以归结到\([1,18]\)的讨论(巴什博奕也是归结到前(1+m))的讨论

上线分别是乘以2,9在变化是因为两个人的扩张策略不一样,Stan先手肯定是尽量乘以大的赢得概率大,从Ollie的角度想,就要乘以小的来尽可能阻止Stan赢

代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
double n;
while(cin >> n)
{
while(n>18) n/=18;
if(n<=9)
cout << "Stan wins.\n";
else
cout << "Ollie wins.\n";
}
return 0;
}

Hdoj 1517.A Multiplication Game 题解的更多相关文章

  1. 【HDU】1517 A Multiplication Game

    http://acm.hdu.edu.cn/showproblem.php?pid=1517 题意:每次乘上2~9..p>=n时赢.. #include <cstdio> #incl ...

  2. HDU 1517 A Multiplication Game (博弈)

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  3. hdu 1517 A Multiplication Game 段sg 博弈 难度:0

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  4. hdu 1517 A Multiplication Game(必胜态,必败态)

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  5. HDU 1517:A Multiplication Game

    A Multiplication Game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot ...

  6. hdu 1517 A Multiplication Game 博弈论

    思路:求必胜区间和必败区间! 1-9 先手胜 10-2*9后手胜 19-2*9*9先手胜 163-2*2*9*9后手胜 …… 易知右区间按9,2交替出现的,所以每次除以18,直到小于18时就可以直接判 ...

  7. (step8.2.7)hdu 1517(A Multiplication Game——巴什博弈变形)

    题目大意:输入一个整数n.谁先报的数大于n,谁就输了.(初始值p  == 1 , 后一个人报的数必须在前一个人报的数的基础上乘上(2 ~ 9)之间的任意一个数) 解题思路:巴什博奕的变形 1) 解题思 ...

  8. HDU 1517 A Multiplication Game 博弈

    题目大意:从1开始Stan与Ollie经行博弈,stan先手,每次将当前数乘上(2~9)间的任意数,最后一次操作后大于等于n的人获胜. 题目思路: 1-9 stan 胜 10-18 ollie胜 19 ...

  9. Hdoj 1392.Surround the Trees 题解

    Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to surround a ...

随机推荐

  1. Dynamics 365-如何下载新版本的Tools

    最近新写了个Plugin,想注册到CRM中,但是使用旧版的PluginRegistration Tool的时候,总是加载不出来Plugin数据,所以寻思下载个最新版的Tool试试.现在下载Tools的 ...

  2. as无法关联git

    转载请标明出处:https://www.cnblogs.com/tangZH/p/10060573.html 从gitlab上面把项目拉下来之后,用as打开,发现as无法关联git,没有git相关的菜 ...

  3. DVWA 黑客攻防演练(六)不安全的验证码 Insecure CAPTCHA

    之前在 CSRF 攻击 的那篇文章的最后,我觉得可以用验证码提高攻击的难度. 若有验证码的话,就比较难被攻击者利用 XSS 漏洞进行的 CSRF 攻击了,因为要识别验证码起码要调用api,跨域会被浏览 ...

  4. SQLServer之修改表值函数

    修改表值函数注意事项 更改先前通过执行 CREATE FUNCTION 语句创建的现有 Transact-SQL 或 CLR 函数,但不更改权限,也不影响任何相关的函数.存储过程或触发器. 不能用 A ...

  5. Canadian-dollar_RMB

    import pandas as pd import matplotlib.pyplot as plt import statsmodels as sm from statsmodels.graphi ...

  6. Python面试笔记四

    数据库 1.将name字段添加索引 create index index_emp_name on student(name); 2.查询女生中数学成绩最高的分数 select max(score) f ...

  7. IDEWorkspaceChecks.plist文件是干什么用的?

    在提交PR的时候,无意间发现了在xcworkspace/xcshareddata中多了一个名为IDEWorkspaceChecks.plist的文件.自己并没有手动创建此文件,在网上查了一下,最终对其 ...

  8. vs 2015安装包

    Visual Studio 2015 下载含(更新3)及密钥 Visual Studio 2015 是一个丰富的集成开发环境,可用于创建出色的 Windows.Android 和 iOS 应用程序以及 ...

  9. DISK 100% BUSY,谁造成的?(ok)

    iostat等命令看到的是系统级的统计,比如下例中我们看到/dev/sdb很忙,如果要追查是哪个进程导致的I/O繁忙,应该怎么办? # iostat -xd ... Device: rrqm/s wr ...

  10. IDEA+API && SPI

    JAVA中API和SPI的区别:https://blog.csdn.net/quanaianzj/article/details/82500019