Predictopus Problem
来源:互联网 发布:用mac硬盘怎么查看内容 编辑:程序博客网 时间:2024/05/22 03:39
Predictopus
Problem code: PREDICT
Chef Datta likes betting in Indian Premier League very much.
He has 10000 rupees. Today the match is between team A andteam B. The winning probability of team A is PA, and hence winning probability ofteam B is PB = 1 − PA.
Datta is free to bet any integral amount of money on any of the two teams as long as the total amount of money bet is at most10000 rupees.
Help him know the expected amount of money he will eventually have if today he places his bet(s) optimally.
Rules of the game:
If team X with winning probability PX actually wins and someone betsM rupees on this team, he will gain (2*(1−PX)) * M rupees.
If team X with winning probability PX actually loses and someone betsN rupees on this team, he will just lose N rupees.
Input
First line contains single integer T, the number of testcases. ThenT lines follow, each line contains PA the probability thatteam A wins.
Output
For each test case output single line containing the expected amount of money Datta will eventually have today if he places his bet(s) optimally. Your answer will be accepted if the absolute error is less than10−6.
Constraints
- 1 ≤ T ≤ 100001 (105+1)
- 0.0 ≤ PA ≤ 1.0
- PA has at most 5 digits after the decimal point.
Example
Input:10.510Output:10098
Example bet:
Look at the following situation:
If chef Datta bets 6,000 on team A and 4,000 onteam B, the expected amount of money he will have after the bet is settled is10,018. Apparently that is not the best he can do ;)
设第一队胜出的几率 为p 投入m。 那么第二队的几率为1-p, 投入为10000 - m ,
那么第一队可以获得的钱为 (m * 2 *( 1 - p ) + m ) * p ;
同理可以得到第二队获得的钱为( (10000-m)*2*p + m ) *(1-p) ;
总的得钱数为(m * 2 *( 1 - p ) + m ) * p + ( (10000-m)*2*p + m ) *(1-p) 。化解即可求得
#include<iostream>#include<cmath>#include<cstdio>using namespace std ;int main(){ int t ; scanf("%d",&t); while(t--){ double px , py , x ; scanf("%lf",&px); py = 1-px ; if(px>py) x = 10000 ; else x = 0 ; printf("%lf\n",(2*px + 1 )*py*10000 + (px-py) * x); } return 0;}
- Predictopus Problem
- problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- 疾病研究:[转帖]定位Utrophin蛋白刹车给治疗杜氏进行性肌营养不良带来了希望
- 高考信息:2007湖北高考分数和录取查询
- 技巧心得:系统配置实用程序详解---优美的旋律,令人难以忘怀!
- 影视欣赏:夜。上海--超清晰DVD版下载
- 心情日记:生活随笔
- Predictopus Problem
- 报告论文:网站后台管理性能优化分析
- 报告论文:程控交换技术的研究
- 心得技巧:我的电脑杀毒方法
- 时事政治:教育又乱收费,到底还要不要农民活啊
- 技巧心得:DOS学习心得(一)
- 技巧心得:网络工程师考试大纲
- 技巧心得:VBS学习心得~~
- 技巧心得:VBS学习心得~~--邮箱另类登陆