HDU-4461 The Power of Xiangqi 签到题
题意:要求计算两个和值比较大小。注意没有马或者是炮的时候能量减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; }