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
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,傻逼题的更多相关文章
-
codeforces gym #101987K -TV ShowGame(2-SAT)
题目链接: https://codeforces.com/gym/101987 题意: 有长度为$n$的只包含$B,R$的字符串 有m种关系,每个关系说出三个位置的确切字符 这三个位置的字符最多有一个 ...
-
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 ...
-
Codeforces Gym 101252D&;&;floyd判圈算法学习笔记
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...
-
Codeforces Gym 101190M Mole Tunnels - 费用流
题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\rig ...
-
Codeforces Gym 101623A - 动态规划
题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分 ...
-
【Codeforces Gym 100725K】Key Insertion
Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K, ...
-
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 ...
-
codeforces gym 100553I
codeforces gym 100553I solution 令a[i]表示位置i的船的编号 研究可以发现,应是从中间开始,往两边跳.... 于是就是一个点往两边的最长下降子序列之和减一 魔改树状数 ...
-
CodeForces Gym 100213F Counterfeit Money
CodeForces Gym题目页面传送门 有\(1\)个\(n1\times m1\)的字符矩阵\(a\)和\(1\)个\(n2\times m2\)的字符矩阵\(b\),求\(a,b\)的最大公共 ...
随机推荐
-
3.awk数组详解及企业实战案例
awk数组详解及企业实战案例 3.打印数组: [root@nfs-server test]# awk 'BEGIN{array[1]="zhurui";array[2]=" ...
-
TTAS Lock C++11 实现
template<class Lock> class Lock_guard{ private: Lock lock; public: explicit Lock_guard(Lock&am ...
-
ecshop 配送方式支持";货到付款";
ecshop配送方式,支持货到付款方法. 打开表 ecs_shipping,找到字段support_cod,修改1则支持货到付款 扩展 问题描述:已经修改了ecs_shipping表里的support ...
-
piwik流量统计系统搭建(apache2.4+piwik+mysql5.6+php5.6.14)
Piwik: 开放源代码的Web统计软件 Piwik是一个PHP和MySQL的开放源代码的Web统计软件. 它给你一些关于你的网站的实用统计报告,比如网页浏览人数, 访问最多的页面, 搜索引擎关键词等 ...
-
ASP.NET MVC4+EasyUI+EntityFrameWork5权限管理系统——菜单模块的实现(二)
ASP.NET MVC4+EasyUI+EntityFrameWork5权限管理系统——数据库的设计(一) 菜单和模块是在同一个表中,采用的是树形结构,模块菜单表结构如下代码: USE [Permis ...
-
servlet从xml提取数据登陆
在xml文档下可以设置参数的初始值,在这里把他当成了数据库在用 <servlet> <description>This is the description of my J2E ...
-
【行为型】Chain of responsibility模式
职责链模式将对象的请求处理组成链式结构,并将请求按链式结构逐个传递下去,直接被其中的某个处理者处理为止.由此可知,职责链模式的适用场合是对指定请求,可以有多个请求处理者(或称为请求响应者),但用户并不 ...
-
CodeIgniter连接数据库及快速入门
原文:CodeIgniter连接数据库及快速入门 一.数据库配置 CodeIgniter 有一个配置文件让你存放数据库连接值(username:用户名,password:密码,database nam ...
-
暑假集训2016day3T1 欧拉回路(UOJ #117欧拉回路)(史上最全的欧拉回路纯无向图/有向图解析)
原题……可惜不会……真是一只大蒟蒻…… ———————————————————————————————— 有一天一位灵魂画师画了一张图,现在要你找出欧拉回路,即在图中找一个环使得每条边都在环上出现恰好 ...
-
hdu 6068--Classic Quotation(kmp+DP)
题目链接 Problem Description When online chatting, we can save what somebody said to form his ''Classic ...