Parlay Wagering
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2833
题意:讲述了一种投小钱赢大钱的赌博方式,初始投入钱m,如果本局赢了,将钱连本带利投入下一局继续赌博。如果本局输了,之前得到的钱全部清零,如果打平,本局不赢钱。每局投入的钱数不能大于一百万,计算连本带利赢得的钱数,如果大于一百万则按赢了一百万。输入t组,然后是初始投入的钱m与赌博的局数n。在n局中,给出每局的Money Line,用于作为比率计算本局赢得的钱数。如果Money Line 大于0,则比率为Money Line/100,结果截取3位小数;否则,比率为100/Money Line,结果截取3位小数。每局赢得的钱数(截取两位小数)=当前投入的赌注*比率。最后得到的钱整数部分按每3位输出一个“,”的形式。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
const int N=;
#define LL long long
struct ndoe
{
LL x;
string s;
} a[N];
char ss[N];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
double m;
int n;
scanf("%lf%d",&m,&n);
for (int i = ; i < n; i++)
{
cin>>a[i].x>>a[i].s;
}
LL sum = m*;
for (int i = ; i < n; i++)
{
if (a[i].s=="Tie")
continue;
else if (a[i].s=="Loss")
{
sum = ;
continue;
}
else
{
LL t1,t2;
if (a[i].x > )
{
t1 = a[i].x*;
t2 = sum*t1/;
sum+=t2;
}
else
{
t1 = */(-a[i].x);
t2 = sum*t1/;
sum+=t2;
}
}
if (sum >= ) sum=;
}
if (sum >= ) sum=;
double ans = sum*0.1/;
sprintf(ss,"%.2f",ans);
stack<char>p;
int i,cnt = ;
printf("$");
for (i = strlen(ss)-; i >= ; --i)
{
p.push(ss[i]);
if (ss[i]=='.')
break;
}
for (int j = i-; j >= ; --j)
{
cnt++;
p.push(ss[j]);
if (cnt%==&&j!=)
p.push(',');
}
while(!p.empty())
{
char ch = p.top();
printf("%c",ch);
p.pop();
}
puts("");
}
return ;
}
Parlay Wagering的更多相关文章
- URAL 1936 Roshambo 题解
http://acm.timus.ru/problem.aspx?space=1&num=1936 F - Roshambo Time Limit:1000MS Memory Limit:65 ...
- 从商业角度探讨API设计
为Web设计.实现和维护API不仅仅是一项挑战:对很多公司来说,这是一项势在必行的任务.本系列将带领读者走过一段旅程,从为API确定业务用例到设计方法论,解决实现难题,并从长远的角度看待在Web上维护 ...
- URAL 1936 Roshambo(求期望)
Description Bootstrap: Wondering how it's played? Will: It's a game of deception. But your bet inclu ...
随机推荐
- 2019西安多校联训 Day1
试题链接:http://www.accoders.com/contest.php?cid=1893 考试密码请私信; T1 明明就是O(n)的模拟,强行打成二分QAQ 思路:判断收尾是否为1或 ...
- mybatis传参总结
注:文章引用部分 mybatis传递参数总结文章内容 一.单个参数 1.基本数据类型 (1)直接使用 List<ChargeRuleDO> tests(long id); <sele ...
- mysql (5.7版本)---的配置
1.去到官方网站下载 https://dev.mysql.com/downloads/installer/ 或者直接下载 --> https://dev.mysql.com/get/Down ...
- WebStorm 格式化代码快捷键
原文链接:https://kaifazhinan.com/webstorm-formatting-code-shortcuts/ 现在平时都是使用 VS Code 作为日常开发工具,偶尔会打开 Web ...
- CentOS7.x的DNS服务的基础配置
一.bind服务器安装 bind:开源.稳定.应用广泛的DNS服务.bind的软件包名bind,服务名称named. 查看是否安装bind, 安装bind包: rpm -qa bind yum -y ...
- buf.readInt32BE()
buf.readInt32BE(offset[, noAssert]) buf.readInt32LE(offset[, noAssert]) offset {Number} 0 <= offs ...
- buf.readIntBE()
buf.readIntBE(offset, byteLength[, noAssert]) buf.readIntLE(offset, byteLength[, noAssert]) offset { ...
- intel compiler的表现
好久没弄这个东西,今天突然想试下,代码没写完,以后补. #include <stdio.h> #include <stdlib.h> #include <time.h&g ...
- Frame Stacking 拓扑排序 图论
Description Consider the following 5 picture frames placed on an 9 x 8 array. ........ ........ .... ...
- 武大OJ 706.Farm
Farmer John has a farm. Betsy, a famous cow, loves running in farmer John's land. The noise she made ...