A multiplication game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5622   Accepted: 2811

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

【思路】

博弈

2<=n<=9,先手必胜

10<=n<=18,先手必败

19<=n<=162,先手必胜

163<=n<=324,先手必败

=-=

【代码】

 #include<cstdio>

 int main() {
double n;
while(scanf("%lf",&n)==) {
while(n>) n/=;
if(n<=) puts("Stan wins.");
else puts("Ollie wins.");
}
return ;
}

poj 2505 A multiplication game(博弈)的更多相关文章

  1. POJ 2505 A multiplication game [博弈]

    题意:两个人做游戏,每个人都可以在自己的回合里将数p乘以2到9之间的一个数,初始时p=1,谁先将p乘到大于等于n就算赢. 思路:一开始我算sg值,结果算来算去都没算明白... 后来看了别人题解,才豁然 ...

  2. POJ 2505 A multiplication game(找规律博弈/贪心)

    题目链接 #include<iostream> #include<cstdio> using namespace std; typedef long long ll; int ...

  3. poj 2505 A multiplication game

    题目 题意:两个人轮流玩游戏,Stan先手,数字 p从1开始,Stan乘以一个2-9的数,然后Ollie再乘以一个2-9的数,直到谁先将p乘到p>=n时那个人就赢了,而且轮到某人时,某人必须乘以 ...

  4. [原博客] POJ 2505 A multiplication game 组合游戏

    题目链接题意: 有一个数p=1,甲乙两人轮流操作,每次可以把p乘2~9中的一个数,给定一个n,当一个人操作后p>=n,那么这个人赢,问先手是否必胜. 必胜状态:存在一种走法走到一个必败状态. 必 ...

  5. POJ 3673 Cow Multiplication

    Cow Multiplication Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13312   Accepted: 93 ...

  6. POJ Football Game 【NIMK博弈 && Bash 博弈】

    Football Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 451   Accepted: 178 Descr ...

  7. Poj 3318 Matrix Multiplication( 矩阵压缩)

    Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18928   Accepted: ...

  8. 数学(矩阵乘法,随机化算法):POJ 3318 Matrix Multiplication

    Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17783   Accepted: ...

  9. poj 3318 Matrix Multiplication

    http://poj.org/problem?id=3318 矩阵A*矩阵B是否等于矩阵C #include <cstdio> #include <cstring> #incl ...

随机推荐

  1. [Cache] C#操作缓存--CacheHelper缓存帮助类 (转载)

    点击下载 CacheHelper.zip CacheHelper 缓存帮助类 C#怎么操作缓存 怎么设置和取缓存数据,都在这个类里面呢 下面看一下代码吧 /// <summary> /// ...

  2. ORACLE里的自增字段设置

    大家都知道吧,这很坑,尤其是用惯了mysql里的自增字段设置,结果oracle里面没有的.oh,no 我用的是12c版本的,它有一个新特性,可以这样设置自增序列,在创建表是,把id设置为自增序列 cr ...

  3. CSS Margin(外边距)

    CSS Margin(外边距)属性定义元素周围的空间. Margin margin清除周围的元素(外边框)的区域.margin没有背景颜色,是完全透明的 margin可以单独改变元素的上,下,左,右边 ...

  4. Ubuntu1404+Django1.9+Apache2.4部署配置2配置文件设置

    转载注明出处,个人博客:http://www.cnblogs.com/wdfwolf3/ Django首要的部署平台是WSGI,它是Python Web服务器和应用的标准.使用Apache和mod_w ...

  5. Command 模式

    Command 模式通过将请求封装到一个对象(Command)中,并将请求的接受者存放具体的 ConcreteCommand 类中(Receiver)中,从而实现调用操作的对象和操作的具体实现 者之间 ...

  6. iterator迭代器的使用

    部分摘自C++ Primer: 所有的标准库容器类都定义了相应的iterator类型,如vector:vector<int>::iterator iter; 这条语句定义了一个名为iter ...

  7. 读书笔记之 - javascript 设计模式 - 享元模式

    本章探讨另一种优化模式-享元模式,它最适合于解决因创建大量类似对象而累及性能的问题.这种模式在javascript中尤其有用,因为复杂的javascript代码很快就会用光浏览器的所有可用内存,通过把 ...

  8. jQuery 鼠标滑过及选中一行效果

    /******* 表格效果 ********/ $("#gird_tbl tbody tr").live('mouseover', function () { $(this).ad ...

  9. 纯javascript联动的例子

    有人想要学习下纯javascript联动的一些技巧,我这里就以日期的联动为例,附上一些代码至于复杂的省市区联动,不建议用纯javascript的,而是用ajax的方式,该不在此讨论范围内,想要了解aj ...

  10. Listview控件实现已选择效果

    Winform中用Listview控件实现更新点击选择后已选择效果,如图: 代码如下: private void frmSelect_Load(object sender, EventArgs e) ...