Hdoj 1517.A Multiplication Game 题解
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 题解的更多相关文章
- 【HDU】1517 A Multiplication Game
http://acm.hdu.edu.cn/showproblem.php?pid=1517 题意:每次乘上2~9..p>=n时赢.. #include <cstdio> #incl ...
- HDU 1517 A Multiplication Game (博弈)
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- hdu 1517 A Multiplication Game 段sg 博弈 难度:0
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- hdu 1517 A Multiplication Game(必胜态,必败态)
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- HDU 1517:A Multiplication Game
A Multiplication Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- hdu 1517 A Multiplication Game 博弈论
思路:求必胜区间和必败区间! 1-9 先手胜 10-2*9后手胜 19-2*9*9先手胜 163-2*2*9*9后手胜 …… 易知右区间按9,2交替出现的,所以每次除以18,直到小于18时就可以直接判 ...
- (step8.2.7)hdu 1517(A Multiplication Game——巴什博弈变形)
题目大意:输入一个整数n.谁先报的数大于n,谁就输了.(初始值p == 1 , 后一个人报的数必须在前一个人报的数的基础上乘上(2 ~ 9)之间的任意一个数) 解题思路:巴什博奕的变形 1) 解题思 ...
- HDU 1517 A Multiplication Game 博弈
题目大意:从1开始Stan与Ollie经行博弈,stan先手,每次将当前数乘上(2~9)间的任意数,最后一次操作后大于等于n的人获胜. 题目思路: 1-9 stan 胜 10-18 ollie胜 19 ...
- 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 ...
随机推荐
- 测者的性能测试手册:Web压力测试工具webbench
webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装: wget http:/ ...
- MySQL中Identifier Case Sensitivity
在MySQL当中,有可能遇到表名大小写敏感的问题.其实这个跟平台(操作系统)有关,也跟系统变量lower_case_table_names有关系.下面总结一下,有兴趣可以查看官方文档"Ide ...
- c/c++ 多线程 mutex的理解
多线程 mutex的理解 mutex,我的理解是每个mutex对象都是一个带锁头的门,这个门有两个状态,门开着和门关着,感觉像是废话... 当想查看门的里东西,或者把东西放进门里,或者从门里拿出东西前 ...
- Ubuntu下crontab启动、重启、关闭命令
在Ubuntu14.04环境下,利用crontab编写shell脚本程序,定时执行php相关程序.在这个过程中,经常使用到的crontab命令如下: (root权限下) crontab启动:/etc/ ...
- DeveloperGuide Hive UDTF
Writing UDTF's Writing UDTF's GenericUDTF Interface GenericUDTF Interface A custom UDTF can be creat ...
- 【题解】P1171 售货员的难题
Tags 搜索,状压. 裸的旅行商问题 #include <stdio.h> #include <string.h> #define re register #define ...
- 【转】Android中保持Service的存活
这几天一直在准备考试,总算有个半天时间可以休息下,写写博客. 如何让Service keep alive是一个很常见的问题. 在APP开发过程中,需要Service持续提供服务的应用场景太多了,比如闹 ...
- 好程序员分享DIV+CSS3和html5+CSS3有什么区别
DIV+CSS3和html5+CSS3有什么区别,不管是DIV+CSS3还是html5+CSS3,他们都是我们对网页开发布局方式的统称,但是DIV+CSS3作为网页的基础开发这句话其实并不严谨,因为而 ...
- ESP8266远程OTA升级
https://blog.csdn.net/xh870189248/article/details/80095139 https://www.wandianshenme.com/play/arduin ...
- springboot2+freemarker简单使用
一.src/main/resources/templates下新建welcome.ftl <!DOCTYPE html> <html lang="en"> ...