B: Bet

题目描述

Josnch星球是一个赌博之风盛行的星球。

每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱。。。)

假设赌博公司的某场赌博有 N 个结果,每个结果能获得的赔率比分别是 a[1],a[2]...a[N]。

假设现在XXX有 X 块钱,问他选择怎样的策略才能使得最坏情况下回报最大?

假设 N 个结果中只有一个是有回报的,X块钱必须全部用在这次赌博上,赔率比就是 a[i],假设你在第 i 个结果中投入了 y 块钱,那么你的回报是 y * a[i],所谓策略是你在每个结果上的投入应该是怎么分配。

比如样例 N = 2 的时候,赔率比分别是1, 2,你有1000块钱,那么买 第一个 2000/3,后一个 1000/3,这样最坏情况下你的回报是 666.67 。

输入

多组数据。

对于每组数据,一个数 N (2 ≤  N ≤  100),N 个选择,接下来一行有 N 个数,每个数的范围是 0.01 ~ 100.00 。

最后一行是一个数 X (0.01 ≤  X ≤  1000.00),代表你的钱总额。

输出

每个输出一行,最坏情况下的最大收益,保留两位小数。

样例输入

2
1 2
1000

样例输出

666.67
 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 int main()
 5 {
 6     int n;
 7     double a[120],x[120],sum=0,ans,v;
 8     while(scanf("%d",&n)!=EOF)
 9     {
10         sum=0,v=0;
11         ans=0;
12         for(int i=1;i<=n;i++)
13         {
14             scanf("%lf",&a[i]);
15             x[i]=a[1]/a[i];
16             sum+=x[i];
17         }
18         scanf("%lf",&v);
19         x[1]=x[1]*(v/sum);
20         ans=a[1]*x[1];
21         printf("%0.2lf\n",ans);
22     }
23     return 0;
24 }
时间: 2024-10-15 06:10:11

B: Bet的相关文章

POJ1644:To Bet or Not To Bet(概率DP)

Description Alexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below. A chip is initially placed on the Start square. The player then trie

uva 1541 - To Bet or Not To Bet(记忆化+概率)

题目链接:uva 1541 - To Bet or Not To Bet 题目大意:在一个棋盘上进行游戏,给定棋盘长度m,不算起始和终止,以及走的步数t.从起点开始,每轮可以丢一枚硬币,正面移动2步,方面移动1步:中间的格子有写操作,包括移动一定步数,停止一次操作.问说在t步内到达终点的概率. 解题思路:dp[i][j]表示走到第i格用掉j步的概率,然后记忆化搜索,因为保证状态重复,并且可以确定递归终止条件. #include <cstdio> #include <cstring>

ACdream 1066:Bet

Problem Description Josnch星球是一个赌博之风盛行的星球.每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱...)假设赌博公司的某场赌博有N个结果,每个结果能获得的赔率比分别是a[1],a[2]...a[N].假设现在XXX有X块钱,问他选择怎样的策略才能使得最坏情况下回报最大(假设N个结果中只有一个是有回报的,X块钱必须全部用在这次赌博上,赔率比就是a[i],假设你在第 i 个结果中投入了 y 块钱,那么你的回报是 y *

UVA 1541 - To Bet or Not To Bet 记忆化DP概率

Alexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below. A chip is initially placed on the Start square. The player then tries to move th

UVA - 1541 To Bet or Not To Bet (DP+概率)

Description Alexander Charles McMillan loves to gamble, and during his last trip to the casino he ran across a new game. It is played on a linear sequence of squares as shown below. A chip is initially placed on the Start square. The player then trie

UVA 1541 - To Bet or Not To Bet(概率递推)

UVA 1541 - To Bet or Not To Bet 题目链接 题意:这题题意真是神了- -,看半天,大概是玩一个游戏,开始在位置0,终点在位置m + 1,每次扔一个硬币,正面走一步,反面走两步,走到的步上有4种情况: 1.向前走n步 2.向后走n步 3.停止一回合 4.无影响 问能在t次机会内,走到终点m + 1(如果跃过也算走到了)的概率,大于0.5,等于0.5,小于0.5对应不同输出 思路:题意懂了就好办了,其实就是递推就可以了dp[i][j]表示第i次机会,落在j步的概率,然后

acdream.Bet(数学推导)

Bet Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Status Practice ACdream 1066 Description Josnch星球是一个赌博之风盛行的星球. 每个人一出生就有一定数额的钱,之后的所有收入只能由赌博获得(OMG,如果RP不好,输光了所有的钱...) 假设赌博公司的某场赌博有 N 个结果,每个结果能获得的赔率比分别是 a[1],a[2]...a[

Bet(The 2016 ACM-ICPC Asia China-Final Contest 思路题)

题目: The Codejamon game is on fire! Fans across the world are predicting and betting on which team will win the game. A gambling company is providing betting odds for all teams; the odds for the ith team is Ai :Bi . For each team, you can bet any posi

How to Construct the Input Bet String

The purpose of this section is to describe the format of the string which will submitted to the Python bet processor strats.py. This string is a series of lines that are Python variable declarative statements. There are a few things that readers not