Problem I. TV Show
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88926#problem/I

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

Sample Output

100

HINT

题意

你正在参加答题活动,每次你可以选择答还是不答,如果你答对了,奖金翻倍,如果答错了,1分钱也拿不到并且滚蛋

答题中你可以买一个保险,使得自己下次就算答错了,也不会有惩罚

题解

我真是日了,我想了一个小时这个傻逼DFS,比赛中没AC

我回去写了N份这道题的不同姿势,全部WA

结果告诉我,是我读题读错了,是我读题读错了,我真是……

这傻逼题

傻逼DFS就好了

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200051
#define mod 10007
#define eps 1e-9
int Num;
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** double p[];
double ans=;
double dp[][];
int n,c;
void dfs(int t,int x,int y,double num,double pp,int k)
{k=;//谁TM告诉我保险如果没用掉,下回合可以接着用的? if(t==x)
{
dp[x][y]+=num*pp;
ans = max(dp[x][y],ans);
return;
}
else if(k==)
{
dfs(t+,x,y,num*,pp*p[t],);
dfs(t+,x,y,num,pp*(-p[t]),);
}
else if(t==y&&num>=c)
{
dfs(t+,x,y,(num-c)*,pp*p[t],);
dfs(t+,x,y,(num-c),pp*(-p[t]),);
}
else
dfs(t+,x,y,num*,pp*p[t],);
}
int main()
{
freopen("tvshow.in","r",stdin);
freopen("tvshow.out","w",stdout);
n=read(),c=read();
for(int i=;i<=n;i++)
{
cin>>p[i];
p[i]/=;
}
for(int j=;j<=n+;j++)
{
for(int k=;k<j;k++)
{
dfs(,j,k,100.0,1.0,);
}
}
printf("%.10lf\n",ans);
}

Codeforces Gym 100338I TV Show 傻逼DFS,傻逼题的更多相关文章

  1. codeforces gym #101987K -TV ShowGame(2-SAT)

    题目链接: https://codeforces.com/gym/101987 题意: 有长度为$n$的只包含$B,R$的字符串 有m种关系,每个关系说出三个位置的确切字符 这三个位置的字符最多有一个 ...

  2. Codeforces Gym 100650C The Game of Efil DFS

    The Game of EfilTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/v ...

  3. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  4. Codeforces Gym 101190M Mole Tunnels - 费用流

    题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...

  5. Codeforces Gym 101623A - 动态规划

    题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...

  6. 【Codeforces Gym 100725K】Key Insertion

    Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K, ...

  7. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

  8. codeforces gym 100553I

    codeforces gym 100553I solution 令a[i]表示位置i的船的编号 研究可以发现,应是从中间开始,往两边跳.... 于是就是一个点往两边的最长下降子序列之和减一 魔改树状数 ...

  9. CodeForces Gym 100213F Counterfeit Money

    CodeForces Gym题目页面传送门 有\(1\)个\(n1\times m1\)的字符矩阵\(a\)和\(1\)个\(n2\times m2\)的字符矩阵\(b\),求\(a,b\)的最大公共 ...

随机推荐

  1. 【JSP】JSP动态显示时间

    function showtime() { var today; var hour; var second; var minute; var year; var month; var date; va ...

  2. jquery加入购物车飞入的效果

    主要原理是:点击当前图片的时候,复制(克隆)当前图片在当前位置,然后利用jQuery的animate()方法实现图像的飞入效果 效果预览:http://runjs.cn/detail/qmf0mtm1 ...

  3. android直接读取数据库文件

    public class Dictionary extends Activity  implements OnClickListener, TextWatcher{     private final ...

  4. ant 安装过程中问题记录

    最近在本机安装ant过程中出现一些问题,在此记录一下. 1.Unable to locate tools.jar. Expected to find it in C:/Program Files/Ja ...

  5. erp验收测试

    软件测试是为了发现错误而执行程序的过程.它不仅是软件开发阶段的有机组成部分,而且在整个软件工程(即软件定义.设计和开发过程)中占据相当大的比重.软件测试是软件质量保证的关键环节,直接影响着软件的质量评 ...

  6. js控制不同的时间段显示不同的css样式

    js控制不同的时间段显示不同的css样式 js函数,可以放到单独的js文件中也可以放到当前页的<head>标记之内 function getCSS(){        datetoday ...

  7. hadoop1.2.1三种模式配置

    1.本地模式 本地模式的安装 将hadoop 安装包解压后不用任何配置就是默认的本地模式 此时 core-site.xml ,hdfs-site.xml , marped.site.xml 三个配置文 ...

  8. andriod的简单用法1

    1.从一个Activity跳转到另一个Activity,使用Intent. 在按钮的onClick中如下写法: public void Login(View view) { Intent intent ...

  9. 将spfile存储在ASM中

    数据库的spfile开始是存储在普通的文件系统中,如下所示: SQL> show parameter spfile NAME TYPE VALUE ----------------------- ...

  10. 使用 CreateInstallMedia 创建 苹果系统安装U盘

    一般来说,从app store上面 下载下来的image位置,都是在 /Applications 下面 使用命令创建安装U盘,(备份一下命令,太长,记不住) sudo /Applications/In ...