您的位置:首页 > 其它

HDU-4461 The Power of Xiangqi 签到题

2013-05-29 21:42 323 查看
题意:要求计算两个和值比较大小。注意没有马或者是炮的时候能量减1,且能量不能小于1。

代码如下:

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

int table[10] = {16, 7, 8, 1, 1, 2, 3};

int main() {
int T;
scanf("%d", &T);
while (T--) {
int x, y, sa = 0, sb = 0;
char str[5];
int m = 0, p = 0;
scanf("%d", &x);
for (int i = 0; i < x; ++i) {
scanf("%s", str);
sa += table[str[0]-'A'];
if (str[0]-'A' == 1) m = 1;
if (str[0]-'A' == 2) p = 1;
}
if (!m || !p) sa = max(1, sa - 1);
m = p = 0;
scanf("%d", &y);
for (int i = 0; i < y; ++i) {
scanf("%s", str);
sb += table[str[0]-'A'];
if (str[0]-'A' == 1) m = 1;
if (str[0]-'A' == 2) p = 1;
}
if (!m || !p) sb = max(1, sb - 1);
if (sa == sb) {
puts("tie");
} else {
puts(sa > sb ? "red" : "black");
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: