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 ...
随机推荐
- .NET和Java之争
这几天连续有多篇文章(详细文章列表在<.NET和Java之争一点随想>和<由优劣语言之争引起的思考>有写)诋毁.NET,这类文章我十几年前就看得多了,只不过十几年前是C和C++ ...
- 从.Net到Java学习第七篇——SpringBoot Redis 缓存穿透
从.Net到Java学习系列目录 场景描述:我们在项目中使用缓存通常都是先检查缓存中是否存在,如果存在直接返回缓存内容,如果不存在就直接查询数据库然后再缓存查询结果返回.这个时候如果我们查询的某一个数 ...
- geth搭建私有网络
geth --rpc --unlock "3ae88fe370c39384fc16da2c9e768cf5d2495b48,81063419f13cab5ac090cd8329d8fff9f ...
- python调用C程序代码
DHT11的驱动使用C语言编写 然后用python调用C的程序 显示温湿度 pycall.py文件如下: #!/usr/bin/env python # -*- coding:utf-8 -*- ...
- Clickhouse v18编译记录
简介 ClickHouse是"战斗民族"俄罗斯搜索巨头Yandex公司开源的一个极具"战斗力"的实时数据分析数据库,是面向 OLAP 的分布式列式DBMS,圈内 ...
- 【English】20190416
anti-money laundering反洗钱[ˈænti][ˈlɔːndərɪŋ] misconduct不当行为[ˌmɪsˈkɑːndʌkt] Currently, she is focus ...
- ThreadPoolExecutor解析
前言:在最新的阿里规范中强制使用ThreadPoolExecutor方式创建线程池,不允许使用Executors,因此有必要对ThreadPoolExecutor进行进一步了解. 1.ThreadPo ...
- (七)Create an Index
Now let’s create an index named "customer" and then list all the indexes again: 现在让我们创建一个名 ...
- 如何解决一个从SkylineGlobe5版本升级到7版本遇到的小问题
前些天,有朋友问,用Skyline5版本开发的WinForm程序,升级到7版本的时候,工程提示下面这样“创建组件AxHost失败”的错误,该如何解决呢? 后来经过百度搜索,找到了这样的答案, 测试发现 ...
- UIGestureRecognizer - BNR
继续上篇UITouch - BNR.该篇将实现线条选择.移动和删除操作. UIGestureRecognizer有一系列子类,每一个子类都用于识别特定的手势.当识别出一个手势时,手势识别器会拦截视图的 ...