首页 > ACM题库 > HDU-杭电 > hdu 3708 Warrior Lady待解决[解题报告]C++
2015
02-21

hdu 3708 Warrior Lady待解决[解题报告]C++

Warrior Lady

问题描述 :

"Killers of Three Kingdoms" is a popular role playing card game designed with the novel Romance of the Three Kingdoms.
Sensor

The game has four kinds of "Equipment Card": "Armour", "Weapon", "+1 horse", "-1 horse". Each player has an equipped-item area to hold equipments. A player is allowed to own only one of each of these 4 equipments in the equipped-item area. Equipments can be replaced by one of the same kind. However, after the replacement, the previous ones would be discarded. For simplicity, cards not belong to equipment (tool cards, basic cards and so on) are united as "Other Card" ignoring their functions in this problem.

Sun Shangxiang(Nickname: Xiangxiang), the lady with bow and arrows, is one of the favorable characters in this game. Her 2nd character ability – "Warrior Lady" (枭姬xiāo jī in Chinese) is described below:

Whenever an equipped card is discarded from the equipped-item area, Xiangxiang can immediately draw 2 cards from the deck. Note that Xiangxiang cannot voluntarily remove her equipped items. She can only replace them.

Now it is Xiangxiang’s turn. She has a certain amount of cards of each kind in her hand and her equipped-item area is empty. Given the number of cards of each kind in the deck, assume that every card in the deck will be taken with equal probability, and Xiangxiang will always equip the "Equipment Card" once she gets it. What is the expected number of cards Xiangxiang can draw in her action phase?

输入:

In the first line there is an integer T, indicates the number of test cases. (T <= 100)

For each case, two lines are given. The first line describes Xiangxiang’s hand cards, 5 integers indicating the number of "Armour", "Weapon", "+1 horse", "-1 horse" and "Other Card" respectively. The second line describes the cards in the deck which has the same format as above. The sum of the 10 integers is no more than 104.

输出:

In the first line there is an integer T, indicates the number of test cases. (T <= 100)

For each case, two lines are given. The first line describes Xiangxiang’s hand cards, 5 integers indicating the number of "Armour", "Weapon", "+1 horse", "-1 horse" and "Other Card" respectively. The second line describes the cards in the deck which has the same format as above. The sum of the 10 integers is no more than 104.

样例输入:

3

2 0 0 0 0
0 0 0 0 1

0 0 0 5 0
0 0 0 0 9

0 0 0 2 0
0 0 0 1 2

样例输出:

Case 1: 1.00
Case 2: 8.00
Case 3: 2.67

Hint
Case 1: Xiangxiang will stop drawing cards when the deck cards are used up. Case 2: Xiangxiang cannot voluntarily remove her equipped items but replace them, so 5 equipments of the same kind can only give her (5 �C 1) * 2 = 8 cards. Case 3: The probability to draw 3 cards is 2/3, and the probability to draw 2 cards is 1/3. So the answer is 3 * (2/3) + 2 * (1/3) = 8/3.


  1. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)

  2. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)

  3. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)

  4. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)

  5. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)

  6. 看了前面的分析,我都不知到说什么了。再不济他要什么就给他什么吧,只要不要命就行!我说的是这个女人哈 ,我把有些东西看得比命还重要~~~~ (你懂的)