1011 World Cup Betting (20 分)

版权声明:如果喜欢的话,请点击一波关注把,谢谢你,么么哒!转载留名即可 ^_^ https://blog.csdn.net/qq_33375598/article/details/86665383

 

With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy(奖杯) in South Africa. Similarly, football betting fans were putting their money where their mouths were, by laying all manner of World Cup bets.

Chinese Football Lottery(抽彩) provided a "Triple(三倍) Winning" game. The rule of winning was simple: first select any three of the games. Then for each selected game, bet on one of the three possible results -- namely W for win, T for tie, and L for lose. There was an odd assigned(分配) to each result. The winner's odd would be the product of the three odds(投注赔率) times 65%.

For example, 3 games' odds are given as the following:

 W    T    L
1.1  2.5  1.7
1.2  3.1  1.6
4.1  1.2  1.1

To obtain the maximum profit, one must buy W for the 3rd game, T for the 2nd game, and T for the 1st game. If each bet takes 2 yuans, then the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 yuans (accurate up to 2 decimal places).

Input Specification:

Each input file contains one test case. Each case contains the betting information of 3 games. Each game occupies a line with three distinct odds corresponding to WT and L.

Output Specification:

For each test case, print in one line the best bet of each game, and the maximum profit accurate up to 2 decimal places. The characters and the number must be separated by one space.

Sample Input:

1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1

Sample Output:

T T W 39.31

参考代码:

//甲 World Cup Betting
#include<cstdio>
char str[3] = {'W','T','L'};
 int main(int argc, char const *argv[])
{
	double a,temp,ans = 1.0;
	int id;
for (int i = 0; i < 3; ++i)
{
	temp = 0.0;
	for (int j = 0; j < 3; ++j)
	{
		scanf("%lf",&a);
		if(a > temp ) {
			temp = a;
		 id = j;
		}
	}
	ans *= temp;
	printf("%c ", str[id]);
}

printf("%.2f\n", (ans*0.65-1)*2);

	return 0;
}	

推荐代码:

#include<cstdio>
#include<cmath>
char str[3] = {'W','T','L'};
 int main(int argc, char const *argv[])
{
	double a,temp,ans = 1.00;
	int id;
for (int i = 0; i < 3; ++i)
{
	temp = 0.0;
	for (int j = 0; j < 3; ++j)
	{
		scanf("%lf",&a);
		if(a > temp ) {
			temp = a;
		 id = j;
		}
	}
	ans *= temp;
	printf("%c ", str[id]);
}

printf("%.2f\n", round(((ans*0.65-1)*2)*100)/100);

	return 0;
}	

 

 

My World Cup

02-07

问题描述 :nnMy 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.nAlice 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.nnFirst of all, you must be familiar with the special dice and cards for My World Cup.nnThe 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.nnThere 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.nnWhen two cards from different sides meet, both of them may take some effect, which depends on both cards’ type:nnNo 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.nn2. 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.nn3. 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.nn4. 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.nnThe game’s process in detail is going to be explained below.nn1. 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.nn2. 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.nn3. 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.nn4. 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.nnNow, 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.nn输入:nnThe input begins with a line containing an integer T (1 <= T <= 30), the number of test cases.nEach 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).nn输出:nnThe input begins with a line containing an integer T (1 <= T <= 30), the number of test cases.nEach 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).nn样例输入:nn21 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 1n样例输出:nn40 问答

没有更多推荐了,返回首页