poj 2505 A multiplication game
来源:互联网 发布:java开源流程引擎源码 编辑:程序博客网 时间:2024/05/16 01:25
A multiplication game
Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u
[Submit] [Go Back] [Status]
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.
Stan wins.
or
Ollie wins.
assuming that both of them play perfectly.
Sample Input
1621734012226
Sample Output
Stan wins.Ollie wins.Stan wins.
[Submit] [Go Back] [Status]
还的确是一个稍有难度博弈的问题(这个可不属于博弈中的任何一个):
题意:游戏规则为:两个人在2-9选数选出之后与p相乘,此时p=p*(2...9);当p>=n时这一方获胜。。
分析:
如果输入是 2 ~ 9 ,(2~9)因为Stan 是先手,所以Stan 必胜
如果输入是 10~18 ,(9+1~9*2)因为Ollie 是后手,不管第一次Stan 乘的是什么,Stan肯定在 2 ~ 9 之间,如果Stan乘以 2 ,那么Ollie就乘以 9 ,就到18了,如果Stan乘以 9 ,那么Ollie乘以大于1的数都都能超过 10 ~ 18 中的任何一个数。Ollie 必胜
如果输入是 19 ~ 162,(9*2+1~9*2*9)那么这个范围是 Stan 的必胜态
如果输入是 10~18 ,(9+1~9*2)因为Ollie 是后手,不管第一次Stan 乘的是什么,Stan肯定在 2 ~ 9 之间,如果Stan乘以 2 ,那么Ollie就乘以 9 ,就到18了,如果Stan乘以 9 ,那么Ollie乘以大于1的数都都能超过 10 ~ 18 中的任何一个数。Ollie 必胜
如果输入是 19 ~ 162,(9*2+1~9*2*9)那么这个范围是 Stan 的必胜态
如果输入是 163 ~ 324 ,(9*2*9+1~9*2*9*2)这是又是Ollie的必胜态
。。。。。。
呵呵所以看代码吧
Problem: M User: sdau_09_zysMemory: 164 KB Time: 0 MSLanguage: C++ Result: AcceptedPublic:
#include <cstdio>#include <iostream>#include <cstring>using namespace std;__int64 p,n,count1;int main(){ while(scanf("%I64d",&n)!=EOF) { count1=0; p=1; while(true) { if(p>=n)break; count1++; if(count1&1)p*=9; else p*=2; } printf("%s\n",count1&1?"Stan wins.":"Ollie wins."); } return 0;}
- poj 2505 A multiplication game
- POJ 2505--A multiplication game
- POJ-2505-A multiplication game
- poj 2505 A multiplication game
- [poj]2505 A multiplication game
- POJ 2505:A multiplication game
- poj 2505 A multiplication game
- poj 2505 A multiplication game(博弈)
- POJ 2505 A multiplication game 组合游戏
- poj 2505 A multiplication game(博弈)
- POJ 2505 A multiplication game(博弈)
- poj 2505 A multiplication game 博弈基础
- [求PN点] poj 2505 A multiplication game
- HDU 1517 (POJ 2505) A Multiplication Game 简单博弈
- POJ 2505 && HDU 1517 A multiplication game(博弈论)
- POJ 2505 A multiplication game(找规律博弈)
- 【POJ 2505】A multiplication game 博弈 - 找规律
- HDU 1517 && poj 2505 A Multiplication Game (基础博弈)
- poj 2348 Euclid's Game
- SQL Server 双机热备(based on log shipping)
- hdu 1394 最小逆序数(线段树版本)
- 当文员需要办公自动化的证吗
- 反射生成T-SQL语句,欢迎大家批评指正,有待改进
- poj 2505 A multiplication game
- SQL Server 2005 双机热备的实现
- Servlet 与 JSP 小结 纯概念
- 取石子游戏
- Java学习资料2900篇1
- 面向对象的设计原则-类设计原则
- Matches Game
- 心情日志
- BootLoader与Linux内核的参数传递