B OOXX Game(FZU 2151)
来源:互联网 发布:淘宝卖家的卡片祝福语 编辑:程序博客网 时间:2024/06/04 19:32
B OOXX Game
Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, there are N*M coins in this board with two symbol “O” or “X”. Then they take turns to choose a grid with symbol “O” and change it into “X”. The game ends when all the symbols in the board are “X”, and the one who cannot play in his (her) turns loses the game. Fat brother and Maze like this kind of OOXX game very much and play it day and night. They don’t even need a little rest after each game!
Here's the problem: Who will win the game if both use the best strategy? You can assume that Maze always goes first.
The first line of the date is an integer T, which is the number of the text cases.
Then T cases follow, each case contains two integers N and M indicate the size of the board. Then goes N line, each line with M character shows the state of the board.
1 <= T <=100, 1 <= n <=100, 1 <= m <=100
For each case, output the case number first, and then output the winner’s name, either Fat brother or Maze. See the sample input and output for more details.
31 4OXXX2 4OOXXOOXX1 2XX
Case 1: MazeCase 2: Fat brotherCase 3: Fat brother
题目的大概意思是有两个人在玩游戏,把‘O’改成‘X’,最后一改的人胜利,默认为每次从Maze开始。
直接判断‘O’的个数就行了,如果是奇数Maze胜利,偶数就Fat brother胜利。
代码如下:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char a[1005][1005];int main(){ int t,k=1; scanf("%d",&t); getchar(); while(t--) { int n,m,ans=0; scanf("%d%d",&n,&m); getchar(); for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { scanf("%c",&a[i][j]); if(a[i][j]=='O') ans++; } getchar(); } printf("Case %d: ",k++); if(ans%2==1) printf("Maze\n"); else printf("Fat brother\n"); } return 0;}
- B OOXX Game(FZU 2151)
- FZU 2151 OOXX Game
- FZU 2151 OOXX Game
- FZU-2151 OOXX Game
- FZU 2151 OOXX Game
- fzu 2146 Easy Game & 2147 A-B Game & 2151 OOXX Game(水题)
- FZU Problem 2151 OOXX Game (数学啊)
- FZU_Problem 2151 OOXX Game
- OOXX Game
- OOXX Game
- FZU2151 OOXX Game
- FZU 2147 A-B Game
- FZU 2147 A-B Game
- FZU-2147 A-B Game
- FZU 2147A-B Game
- FZU 2147 A-B Game
- FZU Problem 2147 A-B Game (数学啊)
- FZU OJ 2147 A-B Game (数学水题)
- Qt获取所有进程、终止某个进程
- C语言实现通讯录-动态内存
- 用于目标检测的rcnn,fast-rcnn,faster-rcnn
- 姿态论文整理--04-Human pose estimation using global and local normalization
- 渗透入门学习之http数据包
- B OOXX Game(FZU 2151)
- 最小的k个数
- HttpWebRequest的GetResponse或GetRequestStream偶尔超时 + 总结各种超时死掉的可能和相应的解决办法
- LeetCode.402 Remove K Digits
- 笔试题3
- Java8中对HashMap的改造
- POJ
- Tomcat类加载机制触发的Too many open files问题分析
- 字节输入输出流