HDU 1517 A Multiplication Game(博弈找规律)
来源:互联网 发布:剑桥少儿英语教学软件 编辑:程序博客网 时间:2024/05/11 18:06
传送门
A Multiplication Game
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5309 Accepted Submission(s): 3021
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.
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.
题目大意:
说给你一个数
现在问你的是谁先让这个
解题思路:
这个题目,其实刚看到的时候也不知道怎么做。因为这也不能用
画了画就发现规律了:
当这个
当这个
当这个
当这个
当这个
通过这些 我们就可以发现一个规律了,所以就可以进行操作了。
/**2016 - 08 - 31 晚上Author: ITAKMotto:今日的我要超越昨日的我,明日的我要胜过今日的我,以创作出更好的代码为目标,不断地超越自己。**/#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <vector>#include <queue>#include <algorithm>#include <set>using namespace std;typedef long long LL;typedef unsigned long long ULL;const int INF = 1e9+5;const int MAXN = 1e4+5;const int MOD = 1e9+7;const double eps = 1e-7;const double PI = acos(-1);using namespace std;LL Scan_LL()///输入外挂{ LL res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}int Scan_Int()///输入外挂{ int res=0,ch,flag=0; if((ch=getchar())=='-') flag=1; else if(ch>='0'&&ch<='9') res=ch-'0'; while((ch=getchar())>='0'&&ch<='9') res=res*10+ch-'0'; return flag?-res:res;}void Out(LL a)///输出外挂{ if(a>9) Out(a/10); putchar(a%10+'0');}int main(){ LL n; while(cin>>n) { LL ans = 9LL, cnt = 0; while(1) { if(ans >= n) break; if(cnt & 1) ans *= 9; else ans *= 2; cnt++; } if(cnt & 1) puts("Ollie wins."); else puts("Stan wins."); } return 0;}
0 0
- hdu 1517 A Multiplication Game(博弈找规律)
- HDU 1517 A Multiplication Game(博弈找规律)
- HDU 1517 A Multiplication Game (博弈、PN态、找规律)*
- HDU 1517 ——A Multiplication Game(博弈)(找规律)
- hdu 1517 A Multiplication Game (博弈——找规律)
- HDU 1517 A Multiplication Game 博弈论+找规律
- A Multiplication Game 1517 (博弈+规律)
- POJ 2505 A multiplication game(找规律博弈)
- 【POJ 2505】A multiplication game 博弈 - 找规律
- poj 2505 A multiplication game (博弈+找规律)
- hdu 1517 A Multiplication Game(规律)
- hdu 1517 - A Multiplication Game(博弈)
- HDU(1517)A Multiplication Game(博弈)
- A Multiplication Game - HDU 1517 博弈
- HDU 1517A Multiplication Game 小聪明博弈
- HDU 1517 A Multiplication Game(博弈)
- HDU 1517 A Multiplication Game(博弈)
- HDU 1517 A Multiplication Game [。。]【博弈】
- laravel 增删查的简单使用
- CALL指令有多少种写法
- Git常用命令总结
- 909422229__JAVA最全总结【必备】
- Complete Guide to Parameter Tuning in XGBoost (with codes in Python)
- HDU 1517 A Multiplication Game(博弈找规律)
- 使用二进制进行DFS 海贼王之伟大航路
- 人工智能十月怀胎记:1955-1956,从孕育到诞生
- JNI log来代替printf打印调试
- 指南第一章 例题二 UVA 11729 Commando War(贪心算法)
- POJ 1947 Rebuilding Roads ( 树形DP )
- BZOJ3441 乌鸦喝水
- Linux下安装Jetty服务器部署Jenkins
- 【第一行代码-Android】学习(一)及在studio的迁移(4)intent学习