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
#include<cstdio> char s[3] = {'W','T','L'}; int main(){ double temp,a,ans = 1.0; int idx; for(int i = 0; i < 3; i++){ temp = 0.0; for(int j = 0; j < 3; j++){ scanf("%lf",&a); if(a > temp) { temp = a; idx = j; } } ans *= temp; printf("%c ",s[idx]); //输入一行系统就会给出一个结果。 } printf("%.2f",(ans*0.65 -1)*2); //收益公式是题目给出的 return 0; }
//18.8.3 #include<cstdio> int main(){ double s[5] = {0},a; int k; for(int i = 1 ; i <= 3; i++){ for(int j = 1 ; j <= 3 ; j++){ scanf("%lf",&a); if(a > s[i]){ s[i] = a; k = j; } } if(k == 1) printf("W "); else if(k == 2) printf("T "); else printf("L "); } printf("%.2f",(s[1]*s[2]*s[3]*0.65-1)*2); return 0; }
20190730
#include<cstdio> #define diff 0.001 double pro[4] = {0}; int w[4] = {0}; char c[4] = {'0','W','T','L'}; int main() { for(int i = 1; i <= 3; i++) { double dMax = 0.0; double temp; int iMax = 0; for(int j = 1; j <= 3; j++) { scanf("%lf",&temp);//如果%f 则pro[i]的值无法输入 if(temp > dMax) { dMax = temp; iMax = j; } } pro[i] = dMax; w[i] = iMax; } for(int i = 1; i <= 3; i++) { printf("%c ",c[w[i]]); } printf("%.2f",(pro[3] * pro[1] * pro[2] * 0.65 -1) * 2); return 0; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)