hdu 4461 The Power of Xiangqi【模拟】水题
来源:互联网 发布:php soapclient xml 编辑:程序博客网 时间:2024/05/24 07:42
The Power of Xiangqi
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2365 Accepted Submission(s): 1241
Problem Description
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
Source
2012 Asia Hangzhou Regional Contest
题目大意:
每个棋子都有对应的价值(题干中表里有说明),让你统计两个人拥有的棋子的价值和,大的一方胜利。
注意如果一个人没有马或者没有炮,需要在总分中-1.当然,价值和不能为负。思路:
按题意模拟即可。
Ac代码:
#include<stdio.h>#include<string.h>using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int n,m; scanf("%d",&n); char a[15]; int suma=0; int flagb=0; int flagc=0; for(int i=0;i<n;i++) { scanf("%s",&a); if(a[0]=='A') { suma+=16; } if(a[0]=='B') { flagb++; suma+=7; } if(a[0]=='C') { flagc++; suma+=8; } if(a[0]=='D') { suma+=1; } if(a[0]=='E') { suma+=1; } if(a[0]=='F') { suma+=2; } if(a[0]=='G') { suma+=3; } } if(flagb==0||flagc==0&&suma>0)suma--; int sumb=0; scanf("%d",&m); flagb=0; flagc=0; for(int i=0;i<m;i++) { scanf("%s",&a); if(a[0]=='A') { sumb+=16; } if(a[0]=='B') { flagb++; sumb+=7; } if(a[0]=='C') { flagc++; sumb+=8; } if(a[0]=='D') { sumb+=1; } if(a[0]=='E') { sumb+=1; } if(a[0]=='F') { sumb+=2; } if(a[0]=='G') { sumb+=3; } } if(flagb==0||flagc==0&&sumb>0)sumb--; if(suma==sumb) { printf("tie\n"); } else if(suma<sumb)printf("black\n"); else printf("red\n"); }}
- hdu 4461 The Power of Xiangqi【模拟】水题
- hdu 4461 The Power of Xiangqi(水题)
- hdu 4461 The Power of Xiangqi(简单模拟)
- hdu(4461) The Power of Xiangqi
- HDU 4461 The Power of Xiangqi
- HDU-#4461 The Power of Xiangqi
- HDU-4461-The Power of Xiangqi
- HDU 4461 The Power of Xiangqi
- HDU 4461 The Power of Xiangqi
- hdu 4461 The Power of Xiangqi(水题)
- HDU 4461 The Power of Xiangqi(水)
- HDU 4461 The Power of Xiangqi(水)
- The Power of Xiangqi(水题)
- hdu4461 The Power of Xiangqi【水题】
- HDU4461:The Power of Xiangqi
- hdu4461 The Power of Xiangqi
- HDU4461 The Power of Xiangqi
- 【杭州赛区现场赛PROBLEM I】阅读理解与模拟-The Power of Xiangqi
- JavaScript之模块化编程(二)
- 支付宝app支付各种坑
- 【原】东方耀REACT-NATIVE学习42,ios日期组件 DatePickerIOS
- MySQL系列第四篇:利用MySQL工具之SQLYog进行数据导入
- [Leetcode] Flatten Binary Tree to Linked List
- hdu 4461 The Power of Xiangqi【模拟】水题
- Web标准续
- spring-boot与mybatis整合优化介绍
- python技巧(3)--python cookbook学习笔记
- jquery表格获取行、列
- Linux常用命令
- 二进制 十进制数的转换
- FragmentTabHost切换Fragment时避免重复加载UI
- CentOS6.5离线安装mysql遇到的几个问题