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. MyEclipse 下用link 方式安装插件

      N年之前,也是Java出身,后来转DBA,Java 就忘的差不多了. 最近计划好好研究下Python,还是选用MyEclipse 这个IDE了,多年没敲代码,很多东西都忘记了,做点笔记,备用. M ...

  2. jquery日历datepicker的使用方法

    jquery.ui.datepicker.js 用法: http://blog.csdn.net/zb0567/article/details/7906238   原文  http://blog.cs ...

  3. HGE初始化状态设置

    HGE_FRAMEFUNC:     最重要的设置,每个HGE应用必须设置.游戏的主循环就是他了.类型为bool*(),返回真那么主循环退出,游戏也就结束了.否则进行必要的处理后返回假.必须在调用进入 ...

  4. GIS中相交的定义(OGC相交的定义)

    我们常用GIS中的相交,比如在地图漫游的时候,屏幕显示的图形和屏幕这个包络线就是相交的关系.我们常用的GIS工具,拉框查询,这个用到的也是相交. 首先题目开起来很简单(开始的时候我是这样想的),但是做 ...

  5. glassfish 一个bug重现

        原文链接:https://java.net/jira/browse/GLASSFISH-21293?jql=project%20%3D%20GLASSFISH%20AND%20resoluti ...

  6. 【暑假】[深入动态规划]UVa 10618 Fun Game

    UVa 10618 Fun Game 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=36035 思路:   一圈人围坐 ...

  7. cubla sample-code

    cublasSscal //Example 1. Application Using C and CUBLAS: 1-based indexing #include <stdlib.h> ...

  8. algorithm@ find kth smallest element in two sorted arrays (O(log n time)

    The trivial way, O(m + n): Merge both arrays and the k-th smallest element could be accessed directl ...

  9. HDU-4336 Card Collector 概率DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意:买食品收集n个卡片,每个卡片的概率分别是pi,且Σp[i]<=1,求收集n个卡片需要 ...

  10. Mongodb 和 普通数据库 各种属性 和语句 的对应

    SQL to MongoDB Mapping Chart In addition to the charts that follow, you might want to consider the F ...