FZUOJ-2275 Game
来源:互联网 发布:linux gzip 解压缩 编辑:程序博客网 时间:2024/06/05 17:47
Accept: 159 Submit: 539
Time Limit: 1000 mSec Memory Limit : 262144 KB
Problem Description
Alice and Bob is playing a game.
Each of them has a number. Alice’s number is A, and Bob’s number is B.
Each turn, one player can do one of the following actions on his own number:
1. Flip: Flip the number. Suppose X = 123456 and after flip, X = 654321
2. Divide. X = X/10. Attention all the numbers are integer. For example X=123456 , after this action X become 12345(but not 12345.6). 0/0=0.
Alice and Bob moves in turn, Alice moves first. Alice can only modify A, Bob can only modify B. If A=B after any player’s action, then Alice win. Otherwise the game keep going on!
Alice wants to win the game, but Bob will try his best to stop Alice.
Suppose Alice and Bob are clever enough, now Alice wants to know whether she can win the game in limited step or the game will never end.
Input
First line contains an integer T (1 ≤ T ≤ 10), represents there are T test cases.
For each test case: Two number A and B. 0<=A,B<=10^100000.
Output
For each test case, if Alice can win the game, output “Alice”. Otherwise output “Bob”.
Sample Input
Sample Output
Hint
For the third sample, Alice flip his number and win the game.
For the last sample, A=B, so Alice win the game immediately even nobody take a move.
Source
第八届福建省大学生程序设计竞赛-重现赛(感谢承办方厦门理工学院)#include#include #include #define _match(a,b) ((a)==(b))using namespace std;const int N = 100000 + 5;typedef char elem_t;char A[N],B[N],C[N];int fail[N];int pat_match(int ls,elem_t* str,int lp,elem_t* pat){ int i,j; fail[0] = -1; for(j=1;j =0&&!_match(pat[i+1],pat[j]);i=fail[i]); fail[j] = (_match(pat[i+1],pat[j])?i+1:-1); } for(i=j=0;i =0){printf("Alice\n");continue;} int k=0; for(int i=lenb-1;i>=0;i--) C[k++] = B[i]; k=0; while(C[k]=='0') {k++;lenb--;} if(pat_match(lena,A,lenb,C+k)>=0){printf("Alice\n");continue;} printf("Bob\n"); }}
- FZUOJ-2275 Game
- fzuoj 2143 Board Game
- fzuoj 2149 Reverse Game
- fzuoj 2150 Fire Game BFS
- fzuoj 2145 Rock-Paper-Scissors Game
- Fzuoj 2260 Card Game【单调栈+Dp】
- [FZUOJ
- FZUOJ 2150 Problem 2150 Fire Game (双起点BFS)
- FZUOJ 2214
- FZUOJ 1894 志愿者选拔
- FZUOJ 2135 数字游戏
- 【FZUOJ 2020】 组合
- FZUOJ 2231 平行四边形数
- FZUOJ-2273 Triangles
- FZUOJ 2273 Triangles
- FZUOJ 2282 Wand
- FZUOJ 2280 Magic
- FZUOJ 2277 Change
- DarkComet木马协议成最多恶意网络协议
- kmp水题理解
- 宿主主机和虚拟机端口映射docker
- ueditor1.4.3 jsp版本图片上传配置问题
- HTTP和HTTPS详解
- FZUOJ-2275 Game
- 犯错的体会,equals和==区别
- 【教程】Edraw Max(亿图图示):思维导图怎样一次性键入分支内容?
- C++11 学习笔记 lambda表达式
- Git常用命令
- 吴恩达又双叒叕刷屏了_你准备入坑了吗?
- SQL总结(六)触发器
- POJ
- Maven学习总结(一)——Maven入门