首页 > 其他分享 >PAT 甲级 1011 World Cup Betting(20)

PAT 甲级 1011 World Cup Betting(20)

时间:2023-03-07 20:14:50浏览次数:31  
标签:PAT Cup int Betting game num each World

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.31yuans (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 W, T 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

Experiential Summing-up

选出每组最大的数,最后根据公式计算即可。

Accepted Code

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int g[3][3];
 4 char s[3]={'W','T','L'};
 5 double sum = 1, num;
 6 
 7 int main()
 8 {
 9     for(int i = 0; i < 3; i ++)
10     {
11         int a = 0;
12         double t = -1.0;
13         for(int j = 0; j < 3; j ++)
14         {
15             cin >> num;
16             if(num > t)
17             {
18                 t = num;
19                 a = j;
20             }
21         }
22         sum *= t;
23         cout << s[a] << " ";
24     }
25     cout << fixed << setprecision(2) << (sum * 0.65 - 1) * 2;
26 }

 

标签:PAT,Cup,int,Betting,game,num,each,World
From: https://www.cnblogs.com/marswithme/p/17189440.html

相关文章

  • ExcelPatternTool: Excel表格-数据库互导工具
    ExcelPatternToolExcel表格-数据库互导工具介绍:指定Pattern文件-一个规则描述的json文档,基于此规则实现Excel表格与数据库之间的导入导出,校验等功能。特点:小巧,轻量......
  • PAT Basic 1012. 数字分类
    PATBasic1012.数字分类1.题目描述:给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字:\(A1\)=能被5整除的数字中所有偶数的和;\(A2\)=将被5除后余......
  • 无线和射频集成电路CC2651R3SIPAT0MOUR/CC2652PSIPMOTR/CC2651P31T0RKPR TxRx + MCU 2
    一、CC2651R3SIPAT0MOUR介绍:CC2651R3SIPA器件是一款多协议2.4GHz无线微控制器(MCU),支持Zigbee®、Bluetooth®5.2LowEnergy、IEEE802.15.4g、TI15.4stack(2.4GHz)......
  • PAT 乙级 1014 题解 (Basic Level) Practice
    很简单的一道题,我的程序有点乱#include<stdio.h>#include<string.h>#include<ctype.h>intmain(){chars1[61];chars2[61];chars3[61];chars4[61];s......
  • 33. CF-Divisor Paths
    链接求从\(x\)到\(y\)的最短路径的数量。显然应该从\(x\)走到\(\gcd(x,y)\)再走到\(y\),容易证明这样走是最优的。那么现在只需要把两段的最短路径数量分别求出......
  • PAT Basic 1009. 说反话
    PATBasic1009.说反话1.题目描述:给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。2.输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的......
  • Linux操作命令(九)1.comm命令 2.diff命令 3.patch命令
    1、comm用于比较两个有序文件的不同,在使用comm指令之前应先把文件的内容进行排序(sort)显示结果包括3列:第1列为只在第一个文件中找到的行,第2列为只在第二个文件中找......
  • PAT 甲级 1009 Product of Polynomials
    Thistime,youaresupposedtofind A×B where A and B aretwopolynomials.InputSpecification:Eachinputfilecontainsonetestcase.Eachcaseoccupi......
  • 《设计模式之禅》Strategy_Pattern--策略模式
    写在前面设计模式之禅这本书也是博主看了几本设计模式的开头才决定以这本书作为学习设计模式的资料。像小傅哥的重学Java设计模式,好处是以真实的项目案例的逻辑来搭配设计模......
  • 高性能 Jsonpath 框架,Snack3 3.2.57 发布
    Snack3,一个高性能的JsonPath框架借鉴了Javascript所有变量由var申明,及Xmldom一切都是Node的设计。其下一切数据都以ONode表示,ONode也即Onenode之意,代表任何......