zoukankan      html  css  js  c++  java
  • FZU 2151 OOXX Game

    OOXX Game
    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    Description

    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.

    Input

    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

    Output

    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.

    Sample Input

    3 1 4 OXXX 2 4 OOXX OOXX 1 2 XX

    Sample Output

    Case 1: Maze Case 2: Fat brother Case 3: Fat brother
     1 #include <stdio.h>
     2 #include <string.h>
     3 
     4 int main()
     5 {
     6     int n,m;
     7     int T,ca=1;
     8     int i,j,k;
     9     char s[105];
    10     scanf("%d",&T);
    11     while(T--)
    12     {
    13         int num=0;
    14         scanf("%d %d",&n,&m);
    15         for(i=1;i<=n;i++)
    16         {
    17             scanf("%s",s);
    18             for(j=0;j<m;j++)
    19                 if(s[j]=='O')
    20                     num++;
    21         }
    22         printf("Case %d: ",ca);
    23         if(num%2==0)
    24             printf("Fat brother
    ");
    25         else
    26             printf("Maze
    ");
    27         ca++;
    28     }
    29     return 0;
    30 }
    View Code
  • 相关阅读:
    asp.net正则匹配嵌套Html标签
    sql语句插入百万测试数据
    js判断网页是真静态还是伪静态的方法
    sql自动创建表并复制数据
    百度地图API-搜索地址、定位、点击获取经纬度并标注
    kindeditor自定义插件插入视频代码
    mongo 取随机100条数据写入Excel
    python实现RSA加密和签名以及分段加解密的方案
    装饰器写法
    大转盘抽奖概率 固定每个区域的中奖几率
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771409.html
Copyright © 2011-2022 走看看