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 ...
随机推荐
- Dynamics 365-Full Text Index on Stopwords
之前写了一篇关于Online Relevance Search的博文,然后又看到罗勇大神关于Full Text Index的博文:Dynamics CRM中一个查找字段引发的[血案],于是准备写点关于 ...
- linux初学者常用必备命令整理
Linux命令学习 1.文件&目录处理 ls -a 全部文件 -l 详细信息 -r 递归显示子目录结构 ls -al 相当于 ls -a -l cd ..上级目录 .当前目录 ~家目录 cd ...
- jsoup爬取网站图片
package com.ij34.JsoupTest; import java.io.File; import java.io.FileOutputStream; import java.io.Inp ...
- 明天研究下jpa直接像django一样生成
https://blog.csdn.net/yztezhl/article/details/79390714 自动生成 教程-- https://blog.csdn.net/mxjesse/artic ...
- 单元测试(qunit)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- axios请求本地的json文件在打包部署到子目录域名下,路径找不到
前言: 因为要同时部署两个项目,有一个是部署到域名下面的子目录下,如:https://xxx.com/siot-admin vue 项目中使用axios请求了本地项目的static文件夹下的json文 ...
- [LeetCode] 15. 三数之和
题目链接:https://leetcode-cn.com/problems/3sum/ 题目描述: 给定一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a ...
- IDEA+API && SPI
JAVA中API和SPI的区别:https://blog.csdn.net/quanaianzj/article/details/82500019
- 传统C/S软件的"断骨增高"
前言: 由于院内临床业务需要高频强功能的用户界面互操作性要求,使得在HIT行业中存在大量的C/S型软件,尽管B/S软件应用范围正在扩大,但在很多场景中,C/S软件仍然顽强的生存和发展着. 不过随着行业 ...
- 玩转3D Swiper美女性感秀之思路分析总结
前言 继一次的3D魔方之后,这次利用CSS3的transform.translate.rotate.preserve-3d等结合JS的requestAnimationFrame.class带你一起玩转 ...