problem

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

tip

answer

#include<bits/stdc++.h>
using namespace std; #define INF 0x3f3f3f3f float GetMax(float a, float b, float c){
return max(max(a, b),c);
} int GetStatus(float a, float b, float c){
if (a > b){
if( a > c) return 0;
else return 2;
}
if(a < b){
if( b > c) return 1;
else return 2;
}
return -1;
}
int main(){
// freopen("test.txt", "r", stdin);
float a, b, c, mul = 1;
for(int i = 0; i < 3; i++){
cin>>a>>b>>c;
mul *= GetMax(a, b, c);
switch(GetStatus(a, b, c)){
case 0: cout<<"W ";break;
case 1: cout<<"T ";break;
case 2: cout<<"L ";break;
default: return -1;
}
} cout<<fixed<<setprecision(2)<<(mul*0.65 - 1)*2;
return 0;
}

experience

  • 加快速度,这题目还要20分钟?

1011 World Cup Betting (20)(20 point(s))的更多相关文章

  1. PAT 甲级 1011 World Cup Betting (20)(20 分)

    1011 World Cup Betting (20)(20 分)提问 With the 2010 FIFA World Cup running, football fans the world ov ...

  2. PAT 甲级 1011 World Cup Betting (20)(代码+思路)

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

  3. 1011 World Cup Betting (20 分)

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

  4. PAT 甲级 1011 World Cup Betting (20)(20 分)(水题,不用特别在乎精度)

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

  5. pat 1011 World Cup Betting(20 分)

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

  6. PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...

  7. PAT甲 1011. World Cup Betting (20) 2016-09-09 23:06 18人阅读 评论(0) 收藏

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

  8. PATA 1011 World Cup Betting (20)

    1011. World Cup Betting (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Wit ...

  9. PAT 1011 World Cup Betting

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

  10. PAT 甲级 1001 A+B Format (20)(20 分)

    1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...

随机推荐

  1. 20155336 2016-2017-2《JAVA程序设计》第七周学习总结

    20155336 2016-2017-2<JAVA程序设计>第七周学习总结 教材学习内容总结 第十三章 认识时间与日期 格林威治标准时间:简称GMT时间,参考格林威治皇家天文台的标准太阳时 ...

  2. windows环境下git的环境变量配置

    1.从官网下载git这个软件.msi格式,然后安装. 2.找到你的git的安装目录,并记录下来 3.配置环境变量:在path里加入——  ;你的git的安装目录\bin;你的git的安装目录\libe ...

  3. 2016.07.13-vector<vector<int>>应用2——Two Sum扩展

    收获: vector<vector<int> >res,不能直接用res[j].push_back(number),因为res[j]是空的,没有初始化 可以先定义 vector ...

  4. JDk1.8源码StringBuffer

    一.概念 StringBuffer A thread-safe, mutable sequence of characters. A string buffer is like a {@link St ...

  5. C 之回调函数

    软件模块之间总是存在着一定的接口,从调用方式上,可以把他们分为三类:同步调用.回调和异步调用.同步调用是一种阻塞式调用,调用方要等待对方执行完毕才返回,它是一种单向调用:回调是一种双向调用模式,也就是 ...

  6. Python基础之多线程事件Event

    import threading,time class Boss(threading.Thread): def run(self): print("BOSS:伙计们今晚上加班到22:00&q ...

  7. textarea保留换行和空格

    <style> pre {white-space: pre-wrap;} </style> //替换textare <pre class="feedback_q ...

  8. python基础--json,pickle和shelve模块

    一.JSON &pickle 用于序列化的两个模块 json,用于字符串 和 python数据类型间进行转换  字符串必须是双引号,不能是单引号 pickle,用于python特有的类型 和 ...

  9. python基础学习之路No.1

    版本python2 python语言不分"和',两者可以一样使用,同等效果 1.输出print python3中print是一个函数 print "hello world" ...

  10. [android] The_connection_to_adb_is_down__and_a_severe_error_has_occured解决方案

    初学安卓,这是我碰到的第一个问题,从网上找了些解决方法,同时也把问题解决了. 方案一 1.先把eclipse关闭. 2.在管理器转到你的android SDK 的platform-tools下, 如图 ...