PAT-1011 World Cup Betting

导读:本篇文章讲解 PAT-1011 World Cup Betting,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

  1. World Cup Betting (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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.13.02.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

比较基础的题目,输入很固定,其实就是每一行代表一场比赛的可能的三种状态以及利率(就是这个意思),分别记录一下每一次比赛的最大利率以及对应的比赛状态,最后在按照题目中的公式计算即可,唯一有点坑人的地方就是题目中的样例是四舍五入的结果,但是经过实验,系统的测试数据是没有四舍五入的,直接舍去了第三位小数之后的数字,这里要注意一下。

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main(){
  double s[3][3];
  int k[3];
  int t;
  double res=1.0;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++)
        cin>>s[i][j];
  }
  for(int i=0; i<3;i++){
    double max=-100;
    for(int j=0 ;j<3; j++){
        if(s[i][j]>max){
            max=s[i][j];
            t=j;
        }
    }
    res*=max;
    k[i]=t;
  }
  for(int i=0; i<3; i++){
    if(i){
        cout<<" ";
    }
    if(k[i]==0)
        cout<<"W";
    else if(k[i]==1)
        cout<<"T";
    else if(k[i]==2)
        cout<<"L";
  }
  printf(" %.2f\n",(res*0.65-1)*2);
  //如果想要四舍五入,可以这样:
  //printf(" %.2f\n",(res*0.65-1)*2+0.005);
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/116841.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!