浙大pat 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 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"iostream"
#include "algorithm"
#include<iomanip>//注意关于小数数位的头文件
using namespace std;
int main()
{
float a[3][3];
int b[3],t=0,temp;
float max,sum=1;
for(int i=0;i<3;i++)
{
max=0;
for(int j=0;j<3;j++)
{
cin >> a[i][j];
if(max<=a[i][j])
{
max = a[i][j];
temp = j;
}
}
b[t++]=temp;
sum *=max;
}
for(int j=0;j<t;j++)
{
if(b[j]==0)
cout<<"W"<<" ";
else if(b[j]==1)
cout<<"T"<<" ";
else
cout<<"L"<<" ";
}
cout<<setiosflags(ios::fixed);//如果为cout<<setiosflags(ios::fixed)<<cout.precision(2);则会输出一个6
cout.precision(2);//设置小数点后为两位
cout<<((sum*0.65-1)*2)<<endl;
return 0;
}
浙大pat 1011题解的更多相关文章
- 浙大pat 1035题解
1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...
- 浙大pat 1025题解
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- 浙大PAT 7-06 题解
#include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...
- 浙大pat 1012题解
1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- 浙大 pat 1003 题解
1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...
- 浙大 pat 1038 题解
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- 浙大 pat 1047题解
1047. Student List for Course (25) 时间限制 400 ms 内存限制 64000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...
- 浙大pat 1054 题解
1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...
- 浙大pat 1059 题解
1059. Prime Factors (25) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...
随机推荐
- angular学习笔记
1.forEach arr:参数是key,index json:与jquery相反,参数是value,key2.str-->json JSON.parse() ang ...
- 读取HttpWebResponse流的两种方法及注意的问题
1. 获取流 HttpWebRequest request= (HttpWebRequest)WebRequest.Create(uri); //构建http request request ...
- VS2015转VS2008
对于Windows8及以上的系统,无法安装VS2008,也不是无法安装,如果玩游戏多的,应该已经安装了.NET3.5,可以正常安装. 既然不能安装VS2008,那就安装VS2015好了,现在已经是Up ...
- windows中操作文件和目录的函数
1.文件操作函数 CreateFile();//创建或打开文件 ReadFile();//从文件读 WriteFile();//向文件写 SetFilePoi ...
- Django之模型管理器filter处理问题
今天上班第一天,恭祝所有朋友新年快乐!! 最近在github上发现一个还不错的基于Django的开源博客项目,不过也许是版本原因,其中代码存在着些许问题,今天主要记录下其中的模型处理方法的部分. 这段 ...
- mob.com Android studio 配置环境
- CVE-2014-1767 利用分析(2015.2)
CVE-2014-1767利用分析 参考这篇文章利用思路,重现利用,主要说明自己在实现的时候遇到的坑. 利用思路 1. 第一次 IoControl,释放 MDL,我们通过 VirtualAddress ...
- php根据IP获取经纬度信息--百度地图篇
一.前言 之前一篇写过 php根据IP获取IP所在城市 ,但是还想再精确一点,获取这个IP所在的经纬度信息,该怎么办呢? 百度地图为我提供了一种解决方案(当然还有其他的解决方案). 先总的来数一下, ...
- Python---day5-各类模块的使用
#_*_coding:utf-8_*_ 时间模块import time # print(time.clock()) #返回处理器时间,3.3开始已废弃 , 改成了time.process_time() ...
- storm实战总结笔记
storm是一款开源的.分布式的.低延迟的.可扩展的.容错的实时计算框架,采用clojure和java的混合编程,总体两者的代码总量是55开的,但clojure语言具有很强的表现力,所以storm的核 ...