编程介的小学生 2017-02-07 04:37 采纳率: 20.5%
浏览 940
已采纳

My World Cup

问题描述 :

My World Cup is a fantastic board game. In this game, controlled by two players respectively, two different soccer teams meet each other in World Cup final. So, both sides are trying their best to win.
Alice and Bob are addicted to My World Cup recently. They always play together. Alice wants to figure out the probability of her winning. She turns to you for help.

First of all, you must be familiar with the special dice and cards for My World Cup.

The dice is six-sided. Two faces have a ball on them, while the other four faces do not. Dice is an important accessory for My World Cup.

There are many cards in My World Cup. Each card belongs to one of four types: foul, offense, defense, and attack. As well, each card has speed and power.

When two cards from different sides meet, both of them may take some effect, which depends on both cards’ type:

No matter your side is home or away,1. If your card is an offense:If the other card is a foul, your card has no effect. Otherwise, your team can have a shoot of your card’s power. A shoot of power k means that you can throw the dice for k times (or do nothing while k is less or equal to zero) . If a ball on the dice is face up for one or more times, your team will score one goal; otherwise, you get nothing. But please note that if the other card is a defense, then before your shoot, your card’s power will be reduced by the defense card’s power.

  1. If your card is a defense:If the other card is an attack, you will make a rapid counter-attack. In the rapid counter-attack, your team will have a shoot of your card’s power minus the attack card’s power.

  2. If your card is an attack:Assume that your card’s power is P1 and the other card’s power is P2. If the other card is a foul, your card will have no effect. If the other card is a defense, your team will score max{ P1-P2,0} goals. Otherwise your team will score P1 goals.

  3. If your card is a foul:You must throw a dice. If a ball on the dice is face up, your opponent will gain a penalty kick(A penalty kick is regarded as a shoot of power 3); otherwise, your card has no effect.

The game’s process in detail is going to be explained below.

  1. Preparation:(1) One player is decided to be home and the other is away.(2) Each player has five cards, four are on the field, one is off the field.

  2. During each turn:(1) Each player selects one card with the largest speed value on his own field. If two or more cards meet the conditions, he can choose anyone among them.(2) Choose the one with larger speed value among two cards selected from step (1) to be the main card. If two cards have the same speed, the one comes from the home team will be chosen.(3) The owner of the main card can choose one card as the subordinate card among the cards in the opponent’s field( including the card selected from step(1) by the opponent).(4) The main card and the subordinate card meet each other and both take their effects. (5) Both the main card and the subordinate card are removed from the field.

  3. After four turns, there is no card on the field. At this time, if a team scores more goals than the other, the victory are theirs. However, if both teams score an equal number of goals, an extra time will be added – each player should put his last card on the field, and the game continues for one more turn.

  4. If the game ends as a draw even after the extra time, well, an exciting penalty shoot-out is used to determine the winner:(1) Teams take turns to take penalty kicks, until each has taken five kicks. However, if one side has scored more goals than the other could possibly reach with all of its remaining penalty kicks, the shoot-out ends immediately.(2) If the teams still have scored an equal number of goals at the end of these five rounds of penalty kicks, sudden death rounds of one penalty kick each are used, until one side scores and the other does not.(3) The team scores more goals at last is the winner.

Now, give you the full information of Alice’s and Bob’s cards, can you calculate the probability of Alice’s winning while both of them are taking optimal strategy to win the game. Note that Alice is always home.

输入:

The input begins with a line containing an integer T (1 <= T <= 30), the number of test cases.
Each test case contains 10 lines. Each line contains three integers t, s and p (0 <= t <= 3, 1 <= s <= 10, 0 <= p <= 9) indicating a single card’s information — t is the type (0 for foul, 1 for offense, 2 for defense, and 3 for attack), s is the speed, and p is the power of the card. The first five cards belong to Alice (first four are on the field and the fifth is off the field), and the last five cards belong to Bob (also first four are on the field and the fifth is off the field initially).

输出:

The input begins with a line containing an integer T (1 <= T <= 30), the number of test cases.
Each test case contains 10 lines. Each line contains three integers t, s and p (0 <= t <= 3, 1 <= s <= 10, 0 <= p <= 9) indicating a single card’s information — t is the type (0 for foul, 1 for offense, 2 for defense, and 3 for attack), s is the speed, and p is the power of the card. The first five cards belong to Alice (first four are on the field and the fifth is off the field), and the last five cards belong to Bob (also first four are on the field and the fifth is off the field initially).

样例输入:

21 6 43 6 12 7 33 5 10 9 02 5 53 3 22 6 43 3 22 5 53 6 13 6 13 6 13 6 13 6 23 6 13 1 33 6 13 6 13 6 1
样例输出:

40

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-02-13 15:39
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码