首页 > 其他分享 >1011 World Cup Betting

1011 World Cup Betting

时间:2023-05-12 18:14:58浏览次数:39  
标签:Cup max Betting each game double World 1011

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 Wfor 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, Tfor the 2nd game, and T for the 1st game. If each bet takes 2 yuans, then the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 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>
#include<iostream>
using namespace std;
char r[] = {' ','W','T','L'};
double max(double a, double b, double c){
    double max = a;
    if(b > max){
        max = b;
    }
    if(c > max){
        max = c;
    }
    return max;
}
int find(double a, double b, double c, double m){
    if(m == a){
        return 1;
    }else if(m == b){
        return 2;
    }else{
        return 3;
    }
}
int main(){
    double w1,t1,l1;
    double w2,t2,l2;
    double w3,t3,l3;
    double p;
    cin>>w1>>t1>>l1;
    double m1 = max(w1, t1, l1);
    cin>>w2>>t2>>l2;
    double m2 = max(w2, t2, l2);
    cin>>w3>>t3>>l3;
    double m3 = max(w3, t3, l3);
    p = (m1 * m2 * m3 * 0.65 - 1) * 2;
    cout<<r[find(w1,t1,l1,m1)]<<" ";
    cout<<r[find(w2,t2,l2,m2)]<<" ";
    cout<<r[find(w3,t3,l3,m3)]<<" ";
    printf("%.2lf", p);
    return 0;
}

 

注意: 

switch-case 不支持double类型的变量

标签:Cup,max,Betting,each,game,double,World,1011
From: https://www.cnblogs.com/yccy/p/17392357.html

相关文章

  • Linux驱动开发笔记(三):基于ubuntu的helloworld驱动源码编写、makefile编写以及驱动编译
    前言  前面学习了驱动的基础框架,上一篇编译了gcc7.3.0,那么为了方便很好的熟悉流程,本篇,将使用ubuntu18.04,直接编译ubuntu18.04的驱动,然后做好本篇文章的相关实战测试。 Ubuntu虚拟机准备步骤一:安装虚拟机  本次使用之前rk3568的ubuntu18.04,笔者没有重新弄了,安装......
  • [Warning] World-writable config file '/etc/my.cnf' is ignored
    告警信息,全局读写配置文件,那么就把权限调整小。 ......
  • Linux驱动开发笔记(一):helloworld驱动源码编写、makefile编写以及驱动编译基本流程
    前言  基于linux的驱动开发学习笔记,本篇是描述了一个字符驱动的基础开发流程,以便做嵌入式开发多年的应用或者系统学习驱动开发。 笔者自身情况  笔者拥有硬件基础,单片机软硬基础,linux系统基础等各种,就是没有linux驱动框架基础,未做过linux系统移植和驱动移植开发了......
  • 【Spring Boot】实战Spring Boot(二)——Hello World 小试牛刀
    一、前言      在上一篇博客,小编向大家介绍了SpringBoot是什么,在上面时候使用。但是空洞的理论的开始总会有一个helloworld的小程序开始,在这篇博客中,小编就向大家介绍一下使用SpringBoot完成一个Helloworld程序。二、环境准备一款不错的IDE:Eclipse、IdeaIntellij(力荐)m......
  • 用DOSBOX运行helloworld程序
    过程:编写---编译---连接---执行目录1,编写2,编译3,链接4,执行5,补充:简捷编译和链接1,编写下面是一段打印"helloworld!"的程序DSEGSEGMENTMESSDB'Hello,World!',0DH,0AH,24HDSEGENDSSSEGSEGMENTPARASTACKDW256DUP(?)SSEGENDSCSEGSEGME......
  • GYM 101147K Touristic Trip
    首先可以看出这是一个条件概率\(P(A/B)=\frac{P(AB)}{P(B)}\),其中\(A\)事件为“满足在\(Z\)城市时寄出第\(Q\)张明信片”,\(B\)事件为“满足得到的明信片序列与给出的明信片序列相同”那只需要求出\(P(AB)\)和\(P(B)\)就能得到最终答案了首先考虑\(B\)事件发现......
  • Hello world
    HelloWorld1.新建文件夹2.新建java文件文件后缀名.javaHello.java【注意】系统可能未显示文件后缀名,要手动打开3.编写代码publicclassHello{publicstaticvoidmain(String[]args){ System.out.print("Hello,World!"); }}4.编译javacJava文件......
  • EJB3.0之HelloWorld
    开发工具:javaee版本的eclipse、JDK1.6、jboss5.0.0注意:jboss的路径不能有中文,否则会报错。新建ejb工程,选择jboss5和ejb3代码:packagecom.ejb;publicinterfaceHelloWorld{ publicStringsayHello(Stringname);}packagecom.ejb;importjavax.ejb.Remote;importjavax.e......
  • freemarker 与 servlet 之 Helloworld版本
    新建web工程,新建servlet类:packagecom.freemaker.servlet;importjava.io.IOException;importjava.io.PrintWriter;importjava.util.HashMap;importjava.util.Map;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.......
  • hello world(参数可以这样写)
    packagetest;importjava.io.ByteArrayOutputStream;importjava.io.FileInputStream;importjava.io.IOException;importjava.io.InputStream;importjava.io.UnsupportedEncodingException;publicclassTest{publicstaticvoidmain(String[]args)throw......