HDU 1517 A Multiplication Game 博弈论+找规律
来源:互联网 发布:网络新技术论文 编辑:程序博客网 时间:2024/05/22 17:36
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 Sample Output Stan wins.
Ollie wins.
Stan wins.
传送门 题意:从1开始,每次乘2~9中的任意一个整数,假如超过或者等于n了就赢, 问最优策略下先手是否必胜。
打表找规律可以发现,先手必败的n有: (9+1)~18 (162+1)~324 …… 可以再打几个表, 然后就可以发现规律,先设一个L=9,R=18, 每次判断n是否在(L+1)~R的范围内,如果在的话就必败; 不然L=R*9,R=L*2,然后继续判断直到L+1>n为止。
……似乎还有更简洁的规律?
Stan wins.
or
Ollie wins.
assuming that both of them play perfectly.
1621734012226
Ollie wins.
Stan wins.
#include<bits/stdc++.h>using namespace std;int main(){int x,L,R;while (~scanf("%d",&x)){L=9,R=18;bool fl=1;while (L+1<=x){if (R>=x){fl=0;break;} else L=R*9,R=L<<1;}if (fl) puts("Stan wins.");else puts("Ollie wins.");}return 0;}
阅读全文
0 0
- HDU 1517 A Multiplication Game 博弈论+找规律
- hdu 1517 A Multiplication Game(博弈找规律)
- HDU 1517 A Multiplication Game(博弈找规律)
- HDU 1517 A Multiplication Game(博弈论)
- hdu 1564 paly a game(博弈论找规律)
- hdu 1517 A Multiplication Game(规律)
- HDU 1517 A Multiplication Game (博弈、PN态、找规律)*
- HDU 1517 ——A Multiplication Game(博弈)(找规律)
- hdu 1517 A Multiplication Game (博弈——找规律)
- POJ 2505 && HDU 1517 A multiplication game(博弈论)
- HDU 1517 A Multiplication Game (博弈论入门题)
- POJ 2505 A multiplication game(找规律博弈)
- 【POJ 2505】A multiplication game 博弈 - 找规律
- poj 2505 A multiplication game (博弈+找规律)
- hdu Calendar Game (博弈论奇偶性找规律)
- hdu 1525 Euclid's Game(博弈论找规律)
- A Multiplication Game 1517 (博弈+规律)
- HDU-1564-Play a game 【找规律】
- 【BZOJ4282】慎二的随机数列
- poj2409 Let it Bead(置换)
- 【BZOJ4282】慎二的随机数列(LIS)
- 自定义圆及箭头加减速
- Python 之 高级面向对象编程 slots
- HDU 1517 A Multiplication Game 博弈论+找规律
- Maximum Subarray:数组中最大连续区间和
- 【BZOJ1880】【SDOI2009】Elaxia的路线
- [BZOJ1880][Sdoi2009] Elaxia的路线 (最短路,拓扑排序)
- qbxt Day 1 乱搞+乱搞+DP
- 判断网络状态
- JavaScript温故知新----Array.sort()
- 2017.10.9 DZY Loves Math VI 失败总结
- 【BZOJ3714】【PA2014】Kuglarz