http://acdream.info/problem?pid=1421

Andrew Stankevich Contest 22

TV Show

Special JudgeTime Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)

Problem Description

      Charlie is going to take part in one famous TV Show. The show is a single player game. Initially the player has 100 dollars. The player is asked n questions, one after another. If the player answers the question correctly, the sum he has is doubled. If the answer is incorrect, the player gets nothing and leaves the show.       Before each question the player can choose to leave the show and take away the prize he already has. Also once in the game the player can buy insurance. Insurance costs c dollars which are subtracted from the sum the player has before the question. Insurance has the following effect: if the player answers the question correctly his prize is doubled as usually, if the player answers incorrectly the prize is not doubled, but the game continues. The player must have more than c dollars to buy insurance.       Charlie’s friend Jerry works on TV so he managed to steal the topics of the questions Charlie will be asked. Therefore for each question i Charlie knows pi — the probability that he will answer this question correctly. Now Charlie would like to develop the optimal strategy to maximize his expected prize. Help him.

Input

      The first line of the input file contains two integer numbers n and c (1 ≤ n ≤ 50, 1 ≤ c ≤ 109). The second line contains n integer numbers ranging from 0 to 100 — the probabilities that Charlie will answer questions correctly, in percent.

Output

      Output one real number — the expected prize of Charlie if he follows the optimal strategy. Your answer must have relative or absolute error within 10-8 .

Sample Input

2 100
50 50
2 50
50 50
2 50
60 0

Sample Output

100
112.5
120

Hint

      The optimal strategy in the second example is to take insurance for the second question. In this case the expected prize is 1/2 × 0 + 1/2 × (1/2 × 150 + 1/2 × 300).       In the third example it is better to leave the show after the first question, because there is no reason to try to answer the second one.

Source

Andrew Stankevich Contest 22

Manager

题意:

有个人参加答题活动,初始有100块,答对一题翻倍,答错一题直接没钱滚蛋。他可以选择在任意时刻拿着现有的钱跑。已知各个题答对的概率,求最高的得钱期望。

还有一个特殊设定,就是他可以在某个时刻买一个保险,保险需要c元,买了的话下一题答错了也不会滚蛋,而是会保持原有钱数继续。

题解:

注意保险只能买一次,直接枚举就行!

(之前以为保险随便买,卧槽,就不会了)

代码:

 //#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define mf1(array) memset(array, -1, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) printf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("huzhi.txt","w",stdout)
#define mp make_pair
#define pb push_back
const double pi=acos(-1.0);
const double eps=1e-; const int maxn=; int n;
double c;
int a[maxn]; inline double dfs(const int &x,const double &s,const bool bought) {
double t=s;
if(x>=n)return s;
t=max(t , a[x]/100.0*dfs(x+ , *s , bought));
if(s>=c && bought!=)t=max(t , dfs(x+ , (a[x]*2.0*(s-c) + (-a[x])*(s-c))/100.0 , ));
return t;
} double farm() {
return dfs(,100.0,);
} int main() {
int i;
while(scanf("%d%lf",&n,&c)!=EOF) {
REP(i,n)RD(a[i]);
printf("%f\n",farm());
}
}

acdream1421 TV Show (枚举)的更多相关文章

  1. UVA1660 电视网络 Cable TV Network

    题目地址:UVA1660 电视网络 Cable TV Network 枚举两个不直接连通的点 \(S\) 和 \(T\) ,求在剩余的 \(n-2\) 个节点中最少去掉多少个可以使 \(S\) 和 \ ...

  2. uva140-暴力枚举

    题意:任意一个点都至少有一个点与其相连接,所有的点可以进行任意排列,总排列数为n!. 一个点带宽定义与它相连的点的最远距离,一个排列的带宽定义为,点中最大的带宽,找出带宽最小的那个排列,有多组,输出字 ...

  3. C# - 集合类

    C#的集合类命名空间介绍: // 程序集 mscorlib.dll System.dll System.Core.dll // 命名空间 using System.Collections:集合的接口和 ...

  4. POJ 1966 Cable TV Network

    Cable TV Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4702   Accepted: 2173 ...

  5. 使用EF自带的EntityState枚举和自定义枚举实现单个和多个实体的增删改查

    本文目录 使用EntityState枚举实现单个实体的增/删/改 增加:DbSet.Add = > EntityState.Added 标记实体为未改变:EntityState.Unchange ...

  6. Cable TV Network-POJ1966图的连通度

    Cable TV Network Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 4404 Accepted: 2047 Desc ...

  7. CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。

    1514: Packs Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 61  Solved: 4[Submit][Status][Web Board] ...

  8. C# 中的枚举类型 enum (属于值类型)

    原文 C# 中的枚举类型 enum (属于值类型) C# 支持两种特殊的值类型:枚举和结构. 声明枚举:声明时要声明所有可能的值. using System; using System.Collect ...

  9. NYOJ 1091 超大01背包(折半枚举)

    这道题乍一看是普通的01背包,最最基础的,但是仔细一看数据,发现普通的根本没法做,仔细观察数组发现n比较小,利用这个特点将它划分为前半部分和后半部分这样就好了,当时在网上找题解,找不到,后来在挑战程序 ...

随机推荐

  1. 【BZOJ-1864】三色二叉树 树形DP

    1864: [Zjoi2006]三色二叉树 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 659  Solved: 469[Submit][Status] ...

  2. 策略设计模式与c语言中的函数指针

    在C语言中有一个非常重要的概念-函数指针,其最重要的功能是实现回调函数(指函数先在某处注册,而它将在稍后某个需要的时候被调用)在java语言中没有指针的概念,但是可以利用接口和指针实现类似的功能,具体 ...

  3. UOJ34 多项式乘法

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...

  4. UOJ244 【UER #7】短路

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000作者博客:http://www.cnblogs.com/ljh2000-jump/转 ...

  5. hdu 1558 线段相交+并查集

    题意:要求相交的线段都要塞进同一个集合里 sol:并查集+判断线段相交即可.n很小所以n^2就可以水过 #include <iostream> #include <cmath> ...

  6. RBD和AOF持久化对比

    RDB和AOF持久化对比 Redis提供了RDB持久化和AOF持久化,本篇文章中将会对这两种机制进行一些对比 RDB机制的优势和略施 RDB持久化是指在指定的时间间隔内将内存中的数据集快照写入磁盘. ...

  7. 【Alpha】团队贡献分配计划

    在仔细看过邹老师的博客和一些主流公司的绩效管理考核方面的内容后,本来我们小组在讨论后决定简化Google的OKR制度,加入一些自己的元素作为我们团队的主要贡献评定制度. OKR就是“目标和关键成果”( ...

  8. wildfly jboss deploy 报 拒绝访问

    用maven clean package wildfly:deploy 部署war,不时报拒绝访问.有时重启wildfly即可.有时需要在standalone.xml中删除war部署: <dep ...

  9. iOS - nil null Nil笔记

    今天查看Nullability and Objective-C发现里面提到了nil和Null等关键字,做一下笔记. nil  ->   Null-Pointer to Objective-C O ...

  10. MooseFs-分布式文件系统系列(一)之了解并安装它

    preface 在上上家公司,曾维护过公司的MFS文件系统,主要用来存储系统日志文件,单纯的把日志当作文件存储,在当时的架构下,MFS就像一个中间站一样,这边程序生成的日志放入MFS,那边日志分析程序 ...