1011. World Cup Betting (20)

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.0 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.0*2.5*65%-1)*2 = 37.98 yuans (accurate up to 2 decimal places).

Input

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

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.0 1.6
4.1 1.2 1.1

Sample Output

T T W 37.98 

代码

 1 #include <stdio.h>
 2 
 3 int findMaxIndex(double*,int);
 4 int main()
 5 {
 6     double odd[],profit;
 7     int index1,index2,index3;
 8     const char outPut[] = {'W','T','L'};
 9     while(scanf("%lf%lf%lf",&odd[],&odd[],&odd[]) != EOF){
         index1 = findMaxIndex(odd,);
         profit = odd[index1];
         scanf("%lf%lf%lf",&odd[],&odd[],&odd[]);
         index2 = findMaxIndex(odd,);
         profit *= odd[index2];
         scanf("%lf%lf%lf",&odd[],&odd[],&odd[]);
         index3 = findMaxIndex(odd,);
         profit *= odd[index3];
         printf("%c ",outPut[index1]);
         printf("%c ",outPut[index2]);
         printf("%c ",outPut[index3]);
         profit = (profit * 0.65 - ) * ;
         printf("%.2lf\n",profit);
     }
     return ;
 }
 
 int findMaxIndex(double *dArray,int n)
 {
     if(n == )
         return -;
     int index = ;
     double maxValue = dArray[];
     int i;
     for(i=;i<n;++i){
         if(maxValue < dArray[i]){
             index = i;
             maxValue = dArray[i];
         }
     }
     return index;
 }

PAT 1011的更多相关文章

  1. PAT 1011 World Cup Betting

    1011 World Cup Betting (20 分)   With the 2010 FIFA World Cup running, football fans the world over w ...

  2. PAT 1011 A+B和C (15)(C++&JAVA&Python)

    1011 A+B和C (15)(15 分) 给定区间[-2^31^, 2^31^]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个 ...

  3. pat 1011 World Cup Betting(20 分)

    1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...

  4. PAT 1011. A+B和C (15)

    给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...

  5. 浙大pat 1011题解

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  6. PAT 1011 A+B和C

    https://pintia.cn/problem-sets/994805260223102976/problems/994805312417021952 给定区间[-2^31^, 2^31^]内的3 ...

  7. PAT——1011. A+B和C

    给定区间[-231, 231]内的3个整数A.B和C,请判断A+B是否大于C. 输入格式: 输入第1行给出正整数T(<=10),是测试用例的个数.随后给出T组测试用例,每组占一行,顺序给出A.B ...

  8. PAT 1011 World Cup Betting 查找元素

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  9. PAT 1011 World Cup Betting (20分) 比较大小难度级别

    题目 With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly exc ...

随机推荐

  1. 理解Android的手势识别

    对于触摸屏,其原生的消息无非按下.抬起.移动这几种,我们只需要简单重载onTouch或者设置触摸侦听器setOnTouchListener即可进行处理.不过,为了提高我们的APP的用户体验,有时候我们 ...

  2. 【译】 AWK教程指南

    前面的话: 这几天写了一个程序,在同一个目录里生成了很多文件,需要统计其中部分文件的总大小,发现经常用到的ls.du等命令都无济于事,我甚至都想到了最笨的方法,写一个脚本:mkdir一个新目录,把要统 ...

  3. [LeetCode]Linked List Cycle II解法学习

    问题描述如下: Given a linked list, return the node where the cycle begins. If there is no cycle, return nu ...

  4. ios开发中,A valid provisioning profile for this executable was not found,的解决方法

    手头上的一个ios项目在上架后,再进行时出现了以上的这个错误,这是上架后忘了对一些配置进行复原 我的项目解决方法是: 是上面的这一块出现了问题,图片上的配置是正常的情况,但是上架的时候对其进行了修改, ...

  5. java deleteOnExit函数用法

    Java的File类中有两个delete方法:delete和deleteOnExit delete无需解释,为直接删除,deleteOnExit文档解释为:在虚拟机终止时,请求删除此抽象路径名表示的文 ...

  6. pip 安装python环境及打包

    0.安装虚拟环境 pip install virtualenv   virtualenv env1   source env1/bin/activate   1. 将包依赖信息保存在requireme ...

  7. leetcode@ [173] Binary Search Tree Iterator (InOrder traversal)

    https://leetcode.com/problems/binary-search-tree-iterator/ Implement an iterator over a binary searc ...

  8. Android反编译基础(apktoos)--广工图书馆APK

    更多精彩内容 :http://www.chenchuangfeng.com QQ:375061590 ------------------------------------------------- ...

  9. ANT打包J2EE项目war包

    1.下载并安装ant 2.安装ant步骤如下 .解压下载的zip包 .进入解压的目录,把bin目录放入系统变量PATH中. eg:E:\dev_tools\apache-ant-\bin .打开cmd ...

  10. 问题-Tbutton(sender) 与 (sender as Tbutton) 等价吗?

    问题:Tbutton(sender) 与 (sender as Tbutton) 等价吗?  答:  1. Sender As TButton时delphi做类型检查. 比如: var frm:TFo ...