时间限制:1 秒

内存限制:32 兆

特殊判题:否

提交:492

解决:219

题目描述:

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).

输入:

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.

输出:

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.

样例输入:
1.1 2.5 1.7
1.2 3.0 1.6
4.1 1.2 1.1
样例输出:
T T W 37.98

思路:

其实就是一个数学算式。

代码:

#include <stdio.h>
#include <string.h> #define N 3 char mtoc(int m)
{
if (m == 0)
return 'W';
if (m == 1)
return 'T';
return 'L';
} int main(void)
{
int n, i, j;
double a[N][N];
int max[N]; n = N;
while (scanf("%lf", &a[0][0]) != EOF)
{
memset(max, 0, sizeof(max));
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if (i == 0 && j == 0)
continue;
scanf("%lf", &a[i][j]);
if (a[i][j] > a[i][max[i]])
max[i] = j;
}
} double res = (a[0][max[0]]*a[1][max[1]]*a[2][max[2]]*0.65-1)*2;
printf("%c %c %c %.2lf\n", mtoc(max[0]),
mtoc(max[1]), mtoc(max[2]), res);
} return 0;
}
/**************************************************************
Problem: 1323
User: liangrx06
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/

九度OJ 1323:World Cup Betting(世界杯) (基础题)的更多相关文章

  1. 九度OJ 1261:寻找峰值点 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:500 解决:37 题目描述: 给定一个整数序列,该整数序列存在着这几种可能:先递增后递减.先递减后递增.全递减.全递增. 请找出那个最大值的 ...

  2. 九度OJ 1158:买房子 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1801 解决:1096 题目描述: 某程序员开始工作,年薪N万,他希望在中关村公馆买一套60平米的房子,现在价格是200万,假设房子价格以每 ...

  3. 九度OJ 1083:特殊乘法 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4114 解决:2809 题目描述: 写个算法,对2个小于1000000000的输入,求结果. 特殊乘法举例:123 * 45 = 1*4 + ...

  4. 九度OJ 1065:输出梯形 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5379 解决:2939 题目描述: 输入一个高度h,输出一个高为h,上底边为h的梯形. 输入: 一个整数h(1<=h<=1000 ...

  5. 九度OJ 1064:反序数 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3758 解决:2773 题目描述: 设N是一个四位数,它的9倍恰好是其反序数(例如:1234的反序数是4321) 求N的值 输入: 程序无任 ...

  6. 九度OJ 1063:整数和 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3456 解决:2254 题目描述: 编写程序,读入一个整数N. 若N为非负数,则计算N到2N之间的整数和: 若N为一个负数,则求2N到N之间 ...

  7. 九度OJ 1062:分段函数 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3306 解决:1952 题目描述: 编写程序,计算下列分段函数y=f(x)的值. y=-x+2.5; 0<=x<2 y=2-1. ...

  8. 九度OJ 1052:找x (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7335 解决:3801 题目描述: 输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数 ...

  9. 九度OJ 1046:求最大值 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9861 解决:4013 题目描述: 输入10个数,要求输出其中的最大值. 输入: 测试数据有多组,每组10个数. 输出: 对于每组输入,请输 ...

  10. 九度OJ 1031:xxx定律 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6058 解决:3816 题目描述:     对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...

随机推荐

  1. 《深入理解Android 卷III》第七章 深入理解SystemUI

    <深入理解Android 卷III>即将公布,作者是张大伟.此书填补了深入理解Android Framework卷中的一个主要空白,即Android Framework中和UI相关的部分. ...

  2. MPTCP 源码分析(一) MPTCP的三次握手

    简述:      MPTCP依然按照正常的TCP进行三次握手,只是在握手过程中增加了MPTCP特有的信息.   建立过程      三次握手过程如下图所示: 左边客户端发送的第一个SYN包携带有客户端 ...

  3. 《学习bash》笔记--进程处理

    1.进程ID和作业编号  当通过附加&号后执行命令时.shell会响应例如以下: $ ls & [1] 3318 当中[1]是作业号,3318是进程号. 一个后台进程完毕时.shell ...

  4. SQL语句练习手册--第二篇

    一.书到用时方恨少:"图书-读者-借阅"类题目 1.1 本题目的表结构 本题用到下面三个关系表: CARDS 借书卡. CNO 卡号,NAME 姓名,CLASS 班级 BOOKS ...

  5. C#操作消息列队

    首先安装消息队列MSMQ,在“计算机管理-服务和应用程序-消息队列-专用队列”中新建列队名称Demo: static void SendAndReceiveMsg() { MessageQueue m ...

  6. linux本地文件上传之RZ/SZ和sftp

    将本地的文件上传到服务器或者从服务器上下载文件到本地,rz / sz命令很方便的帮我们实现了这个功能,但是很多Linux系统初始并没有这两个命令. 1.软件安装 (1)编译安装 root 账号登陆后, ...

  7. java中volatile关键字的含义(转)

    在java线程并发处理中,有一个关键字volatile的使用目前存在很大的混淆,以为使用这个关键字,在进行多线程并发处理的时候就可以万事大吉. Java语言是支持多线程的,为了解决线程并发的问题,在语 ...

  8. Laravel 数据库实例教程 —— 使用DB门面操作数据库

    Laravel支持多种数据库,包括MySQL.Postgres.SQLite和SQL Server,在Laravel中连接数据库和查询数据库都非常简单,我们可以使用多种方式与数据库进行交互,包括原生S ...

  9. 安卓SAX解析XML文件

    XML文件经常使用的解析方式有DOM解析,SAX解析. 一.Sax SAX(simpleAPIforXML)是一种XML解析的替代方法. 相比于DOM.SAX是一种速度更快,更有效的方法. 它逐行扫描 ...

  10. linux权限的深入讨论

    1.      怎样查看文件的权限 1)      掌握使用ls –l命令查看文件上所设定的权限. drwxr-xr-x. 2 root root 6 May 26 2017 binfmt.d 权限信 ...