九度OJ 1323:World Cup Betting(世界杯) (基础题)
时间限制: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.1To 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(世界杯) (基础题)的更多相关文章
- 九度OJ 1261:寻找峰值点 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:500 解决:37 题目描述: 给定一个整数序列,该整数序列存在着这几种可能:先递增后递减.先递减后递增.全递减.全递增. 请找出那个最大值的 ...
- 九度OJ 1158:买房子 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1801 解决:1096 题目描述: 某程序员开始工作,年薪N万,他希望在中关村公馆买一套60平米的房子,现在价格是200万,假设房子价格以每 ...
- 九度OJ 1083:特殊乘法 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4114 解决:2809 题目描述: 写个算法,对2个小于1000000000的输入,求结果. 特殊乘法举例:123 * 45 = 1*4 + ...
- 九度OJ 1065:输出梯形 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5379 解决:2939 题目描述: 输入一个高度h,输出一个高为h,上底边为h的梯形. 输入: 一个整数h(1<=h<=1000 ...
- 九度OJ 1064:反序数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3758 解决:2773 题目描述: 设N是一个四位数,它的9倍恰好是其反序数(例如:1234的反序数是4321) 求N的值 输入: 程序无任 ...
- 九度OJ 1063:整数和 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3456 解决:2254 题目描述: 编写程序,读入一个整数N. 若N为非负数,则计算N到2N之间的整数和: 若N为一个负数,则求2N到N之间 ...
- 九度OJ 1062:分段函数 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3306 解决:1952 题目描述: 编写程序,计算下列分段函数y=f(x)的值. y=-x+2.5; 0<=x<2 y=2-1. ...
- 九度OJ 1052:找x (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7335 解决:3801 题目描述: 输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数 ...
- 九度OJ 1046:求最大值 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9861 解决:4013 题目描述: 输入10个数,要求输出其中的最大值. 输入: 测试数据有多组,每组10个数. 输出: 对于每组输入,请输 ...
- 九度OJ 1031:xxx定律 (基础题)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6058 解决:3816 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ 1后砍掉一半,直到该数 ...
随机推荐
- Spring Bean Life Cycle Methods – InitializingBean, DisposableBean, @PostConstruct, @PreDestroy and *Aware interfaces
Spring Beans are the most important part of any Spring application. Spring ApplicationContext is res ...
- 转:100.64. 开头IP地址问题
100.64. 开头IP地址问题 姚洪楼 发表于 学习备忘录 分类,标签: 电信 08二月2015 0 之前调试过一个路由器在成功设置DDNS的情况下外网依旧无法访问的情况,当时没有多想什么,一直以为 ...
- keycode值大全
13 我们只知道13是回车,主要是其他的也不是很常用,所以不用记. keycode 8 = BackSpace BackSpace keycode 9 = Tab Tab keycode 12 ...
- ES8新特性
Object.values/Object.entries Object.values和 Object.entries是在ES2017规格中,它和Object.keys类似,返回数组类型,其序号和Obj ...
- vue 访问子组件示例 或者子元素
1.子组件 <base-input ref="usernameInput"></base-input> this.$refs.usernameInput 2 ...
- spring 国际化-i18n
i18n(其 来源是英文单词 internationalization的首末字符i和n,18为中间的字符数)是“国际化”的简称.在资讯领域,国际化(i18n)指让产品(出版 物,软件,硬件等)无需做大 ...
- src-resolve: 无法将名称 'extension' 解析为 'element declaration' 组件。
activiti流程部署时,出现“src-resolve: 无法将名称 'extension' 解析为 'element declaration' 组件.”错误. 出错原因:项目所在路径中有中文.
- Android中database所在文件夹路径(9.6)
1 sd----->data---->对应app---->databases----->创建的db 2 push到pc上,可以使用GUI工具SQLiteSpy直接查看datab ...
- 自己动手开发IOC容器
前两天写简历.写了一句:精通Spring IoC容器.怎么个精通法?还是自己动手写个IOC容器吧. 什么是IoC(Inversion of Control)?什么是DI(Dependency Inje ...
- SD--怎样增强是同一类出库单使用不同号码段
在现实的业务中,一个公司有多个销售组织,它们使用同一个出库类型,业务往往希望它们创建的出库单的号码採用不同号码范围.但在sap里出库单号码范围是在出库单类型里设置,也就是使用同样的出库单类型,也就使用 ...