zoukankan      html  css  js  c++  java
  • hdu 4461,水题

    I. The Power of Xiangqi

    1000ms
    1000ms
    32768KB
    64-bit integer IO format: %I64d      Java class name: Main
    Font Size:

    Xiangqi is one of the most popular two-player board games in China. The game represents a battle between two armies with the goal of capturing the enemy’s “general” piece.
    Now we introduce some basic rules of Xiangqi. Xiangqi is played on a 10×9 board and the pieces are placed on the intersections (points). There are two groups of pieces marked by black or red Chinese characters, belonging to the two players separately. During the game, each player in turn moves one piece from the point it occupies to another point. No two pieces can occupy the same point at the same time. A piece can be moved onto a point occupied by an enemy piece, in which case the enemy piece is "captured" and removed from the board. When the general is in danger of being captured by the enemy player on the enemy player’s next move, the enemy player is said to have "delivered a check". If the general's player can make no move to prevent the general's capture by next enemy move, the situation is called “checkmate”.
    Each player has 7 kinds of pieces in this game. Their names, offense power and symbol letters are shown in the table below:



    Now show you the pieces of red player and black player, you are going to find out which player has the larger total offense power. Since Ma and Pao working together can have good effect, if a player has no Ma or no Pao, or has neither, his total offense power will be decreased by one. But the total offense power can't be decreased to zero, it is at least one.

    Input

    The first line is an integer T ( T <= 20) meaning there are T test cases.
    For each test case: The first line shows which pieces the red player has. It begins with an integer n ( 0 < n <= 16) meaning the number of pieces.
    Then n letters follows, all separated by one or more blanks. Each letter is a symbol letter standing for a piece, as shown in the table above.
    The second line describes the situation of the black player, in the same format as the first line.

    Output

    For each test case, if the red player has more offense power, then print "red". If the black player has more offense power, then print "black". If there is a tie, print "tie".

    Sample Input

    3
    2 A B
    2 A B
    7 A A B C D D F 
    7 A A B B C C F
    5 A A B B F
    3 A B F

    Sample Output

    tie
    black
    red
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<vector>
    #include<cstdlib>
    #include<algorithm>
    
    using namespace std;
    
    #define LL long long
    #define ULL unsigned long long
    #define UINT unsigned int
    #define MAX_INT 0x7fffffff
    #define MAX_LL 0x7fffffffffffffff
    #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
    #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
    
    int h[333];
    
    void get_ans(int &ans){
        int n;
        char ch;
        memset(h,0,sizeof(h));
        scanf(" %d",&n);
        for(int i=0; i<n; ){
            ch=getchar();
            i++;
            if(ch=='A') ans+=16;
            else if(ch=='B') ans+=7;
            else if(ch=='C') ans+=8;
            else if(ch=='D') ans+=1;
            else if(ch=='E') ans+=1;
            else if(ch=='F') ans+=2;
            else if(ch=='G')ans+=3;
            else i--;
            h[ch]++;
        }
        if(!h['B'] || !h['C'] && ans>1) ans--;
    }
    
    int main(){
    //  freopen("C:\Users\Administrator\Desktop\in.txt","r",stdin);
    
        int cas;
        scanf(" %d",&cas);
        while(cas--){
            int i,j,n;
            char ch;
            int red=0,black=0;
            get_ans(red);
            get_ans(black);
            if(red>black) printf("red
    ");
            else if(red==black) printf("tie
    ");
            else printf("black
    ");
        }
    
        return 0;
    }
    
  • 相关阅读:
    使用Visual Studio给SharePoint列表添加Event Receiver
    使用客户端对象模型回写SharePoint列表
    思考:通过源码进行安装的前提是什么
    思考:学习一门语言真的是仅仅只有为了使用吗?或者说学习一个语言如果在工作中不使用,那么学习它还有什么好处和价值呢?
    思考:(使用下载工具比如yum,maven等)下载(库或者jar)到本地都需要设置源
    思考:代码块的大小是进行代码抽出一个方法或者进行重构或者是否在设计时设计为一个方法的衡量因素之一吗?
    思考:对源的包装是为了更好的隔离和在中间插入一些层?
    Spring Cloud和Spring Boot的认识
    如何对待基础知识:
    为什么总觉得事情应付不过来,总觉得事情需要花费很多时间?
  • 原文地址:https://www.cnblogs.com/ramanujan/p/3412917.html
Copyright © 2011-2022 走看看