zoukankan      html  css  js  c++  java
  • HDU 4461 The Power of Xiangqi 模拟题

    解题报告:

    题目大意:现有两个人在下中国象棋,给出一种局面,问谁的攻击力更大,通过判断双方持有的子的总的分数加起来,看谁的分数更大,每个棋子有一个对应的分数。

    模拟题,要注意的是题目中有说明,炮和马是绝配,当哪一方一个马都没有或者一个炮或者两种都没有的 话,那么它的攻击力要减少1。

     1 #include<cstdio>
     2 #include<cmath>
     3 int score[8]={16,7,8,1,1,2,3};
     4 int main() {
     5     int T,n,score1,score2;
     6     char ch[5];
     7     scanf("%d",&T);
     8     while(T--) {
     9         score1=score2=0;
    10         scanf("%d",&n);
    11         int flag=0;
    12         while(n--) {
    13             scanf("%s",ch);
    14             if(ch[0]=='B'||ch[0]=='C')
    15             flag++;
    16             score1+=score[ch[0]-'A'];
    17         }
    18         if(flag<2)
    19         score1--;
    20         scanf("%d",&n);
    21         flag=0;
    22         while(n--) {
    23             scanf("%s",ch);
    24             if(ch[0]=='B'||ch[0]=='C')
    25             flag++;
    26             score2+=score[ch[0]-'A'];
    27         }
    28         if(flag<2)
    29         score2--;
    30         if(score1>score2)
    31         printf("red\n");
    32         else if(score1<score2)
    33         printf("black\n");
    34         else
    35         printf("tie\n");
    36     }
    37     return 0;
    38 }
    View Code
  • 相关阅读:
    maven工程的目录结构
    集合的区别
    名词解析
    1.(字符串)-判断字符串是否是子集字符串
    1.(字符串)-判断两字符串是否相等
    python max函数技巧
    1.(字符串)-子字符串位置查找
    numpy线性代数np.linalg
    Python图像库PIL 使用
    pyhthon-chr
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3104246.html
Copyright © 2011-2022 走看看