您的位置:首页 > 其它

HDU 4461 The Power of Xiangqi 模拟题

2013-05-28 19:12 447 查看
解题报告:

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

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

#include<cstdio>
#include<cmath>
int score[8]={16,7,8,1,1,2,3};
int main() {
int T,n,score1,score2;
char ch[5];
scanf("%d",&T);
while(T--) {
score1=score2=0;
scanf("%d",&n);
int flag=0;
while(n--) {
scanf("%s",ch);
if(ch[0]=='B'||ch[0]=='C')
flag++;
score1+=score[ch[0]-'A'];
}
if(flag<2)
score1--;
scanf("%d",&n);
flag=0;
while(n--) {
scanf("%s",ch);
if(ch[0]=='B'||ch[0]=='C')
flag++;
score2+=score[ch[0]-'A'];
}
if(flag<2)
score2--;
if(score1>score2)
printf("red\n");
else if(score1<score2)
printf("black\n");
else
printf("tie\n");
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: