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. 【众秒之门 JavaScript与jQuery技术精粹 #BOOK#】第1章 初学JavaScript需知的七件事

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  2. apache开源项目-- OODT

    Apache OODT (Object Oriented Data Technology) OODT 面向对象的数据技术,开发和促进科学数据管理和归档制度,使跨学科和天体物理学之间的互操作性,行星和空 ...

  3. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.5

    Show that the inner product $$\bex \sef{x_1\vee \cdots \vee x_k,y_1\vee \cdots\vee y_k} \eex$$ is eq ...

  4. 《深入Java虚拟机学习笔记》- 第3章 安全

    3.1为什么需要安全性 Java的安全模型是其多个重要结构特点之一,它使Java成为适于网络环境的技术.因为网络提供了一条攻击连人的计算机的潜在途径,因此安全性是非常重要的.Java安全模型侧重于保护 ...

  5. NGINX(一)内存结构

    ngx_buf_t和ngx_chain_t是nginx中操作内存的重要手段, 很多的数据都需要通过这个结构进行保存. 其中ngx_buf_t中保存一块可用内存, ngx_chain_t则是将内存块连接 ...

  6. HUST 1017 Exact cover dance links

    学习:请看 www.cnblogs.com/jh818012/p/3252154.html 模板题,上代码 #include<cstdio> #include<cstring> ...

  7. 【译】 AWK教程指南

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

  8. MyEclipse 10优化技巧

    MyEclipse 10优化速度方案仍然主要有这么几个方面:去除无需加载的模块.取消冗余的配置.去除不必要的检查.关闭更新. 第一步: 去除不需要加载的模块 一个系统20%的功能往往能够满足80%的需 ...

  9. matlab 函数说明--waitforbuttonpress

    这个函数的名称取得不是太好,一眼看去,好像是等待按键的意思,但是实际上它等待的是按键或者鼠标事件,他的功能描述如下: 停止脚本的执行,直至当前活动的窗口上检测到了鼠标按下事件或者有效的键盘事件(有效是 ...

  10. adb 启动失败的原因和修改adb端口号

    在我们使用Android Studio的时候,有时候就会出现adb打开失败或者启动不了的情况. adb 启动失败的原因:有其他程序占用了adb默认启动的端口号(像我就遇到过,每次只要提前启动了酷狗音乐 ...