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 ( 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

思路:每轮找出最大值的索引,然后再根据索引和公式计算,最后输出。
 #include <stdio.h>
double a[][];
int main()
{
char b[]={'W','T','L'};
int c[];
double maxa=;
for(int i=;i<;i++){
maxa=;
for(int j=;j<;j++){
scanf("%lf",&a[i][j]);
if(a[i][j]>maxa){
maxa=a[i][j];
c[i]=j;
}
}
}
double sum=;
for(int i=;i<;i++){
sum*=a[i][c[i]];
}
sum=sum*0.65-;
sum*=;
printf("%c %c %c %.2f\n",b[c[]],b[c[]],b[c[]],sum);
return ;
}

PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)的更多相关文章

  1. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  2. 【PAT Advanced Level】1011. World Cup Betting (20)

    简单模拟题,遍历一遍即可.考察输入输出. #include <iostream> #include <string> #include <stdio.h> #inc ...

  3. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  4. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  5. PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...

  6. PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...

  7. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  8. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)

    People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...

  9. PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

随机推荐

  1. LVM 逻辑卷 (logica volume manager)

    逻辑卷轴管理员 (Logical Volume Manager) 想像一个情况,你在当初规划主机的时候将 /home 只给他 50G ,等到使用者众多之后导致这个 filesystem 不够大, 此时 ...

  2. centos6.x下使用xinetd管理rsync服务

    系统环境说明:centos6.x,centos7.x下rsync直接可由systemd管理(无需使用xinetd). [root@meinv01 ~]# rpm -qa|grep xinetd [ro ...

  3. 【5min+】 设计模式的迷惑?Provider vs Factory

    系列介绍 [五分钟的dotnet]是一个利用您的碎片化时间来学习和丰富.net知识的博文系列.它所包含了.net体系中可能会涉及到的方方面面,比如C#的小细节,AspnetCore,微服务中的.net ...

  4. ab使用详解—如何使用apache性能测试工具进行压力测试

    作为后端工程师,除了实现业务需求之外,需要考虑的就是自己写的服务,在大并发下是否能正常运行了.但是,在一般开发情况下,没那么多大并发情况让你测试,那该怎么办呢? 这时候,我们就可以用到apache的压 ...

  5. 一条Sql的Spark之旅

    背景 ​ SQL作为一门标准的.通用的.简单的DSL,在大数据分析中有着越来越重要的地位;Spark在批处理引擎领域当前也是处于绝对的地位,而Spark2.0中的SparkSQL也支持ANSI-SQL ...

  6. StarUML之九、starUML的一些特殊属性的说明

    UML的扩充性机制允许你在控制的方式下扩充UML语言. 这一类的机制包括:stereotype,标记值.约束. Stereotype扩充了UML的词汇表,允许你创建新的建筑块,这些建筑块从已有的继承而 ...

  7. Linux_simpl shell-利用Shell脚本for循环输出系统中的用户及其Shell

    [root@localhost ~]# vim user.sh 1 #!/bin/bash 2 for i in `cut -d ":" -f1 /etc/passwd`; 3 d ...

  8. ggEditor给节点增加提示框

    参考官方文档: https://www.yuque.com/antv/g6/plugin.tool.tooltip 在react-ggEditor使用方法: import React from 're ...

  9. System.Text.Json 自定义Converter实现时间转换

    Newtonsoft.Json与System.Text.Json区别 在 Newtonsoft.Json中可以使用例如 .AddJsonOptions(options => { options. ...

  10. python选课系统作业

    # 选课系统# 角色:学校.学员.课程.讲师# 要求:# 1. 创建北京.上海 2 所学校# 2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海 ...