题意:你开始有 s 元钱,然后你要在 t 场内赚到 n 元,每次赢的概率是 p,并且要越快越好。

析:当时没注意这个条件,要越快越好,然后写概率dp,怎么看也不像是对。其实是每次赌 min(s, n-s),尽快结束,就两种决策,要么赢,要么输,

就简单了。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e4 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int s, t;
double p, q; double dfs(int time, int s){
if(s >= n) return 1.0;
if(s <= 0) return 0.0;
if(time <= 0) return 0.0; double ans = 0.0;
ans += dfs(time - 1, s + min(s, n-s)) * p;
ans += dfs(time - 1, s - min(s, n-s)) * q;
return ans;
} int main(){
freopen("betting.in", "r", stdin);
freopen("betting.out", "w", stdout);
while(scanf("%d %d %lf %d", &n, &s, &p, &t) == 4 && n){
p /= 100.0; q = 1.0 - p;
double ans = dfs(t, s);
printf("%.10f\n", ans);
}
return 0;
}

Gym 100512B Betting Fast (题意+概率)的更多相关文章

  1. GYM 100608G 记忆化搜索+概率 2014-2015 Winter Petrozavodsk Camp, Andrew Stankevich Contest 47 (ASC 47)

    https://codeforces.com/gym/100608 题意: 两个人玩游戏,每个人有一个长为d的b进制数字,两个人轮流摇一个$[0,b-1]$的骰子,并将选出的数字填入自己的d个空位之中 ...

  2. Codeforces 866C Gotta Go Fast - 动态规划 - 概率与期望 - 二分答案

    You're trying to set the record on your favorite video game. The game consists of N levels, which mu ...

  3. Gym 101606 F-Flipping Coins(概率dp)

    参考博客:http://www.cnblogs.com/kang000/p/8571071.html  (这篇博客写的真的走心,ORZ) 题意有n个硬币排成一排,开始的时候所有的硬币都是正面朝下,你必 ...

  4. Gym 101174D Dinner Bet(概率DP)题解

    题意:n个球,两个人每人选C个球作为目标,然后放回.每回合有放回的拿出D个球,如果有目标球,就实现了这个目标,直到至少一个人实现了所有目标游戏结束.问结束回合的期望.误差1e-3以内. 思路:概率DP ...

  5. Gym 100952B&&2015 HIAST Collegiate Programming Contest B. New Job【模拟】

    B. New Job time limit per test:1 second memory limit per test:64 megabytes input:standard input outp ...

  6. 【CF865C】Gotta Go Fast 二分+期望DP

    [CF865C]Gotta Go Fast 题意:有n个关卡需要依次通过,第i关有pi的概率要花ai时间通过,有1-pi的概率要花bi时间通过,你的目标是花费不超过m的时间通关,每一关开始时你都可以选 ...

  7. Gym 101102A Coins -- 2016 ACM Amman Collegiate Programming Contest(01背包变形)

    A - Coins Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Descript ...

  8. Gym 100952J&&2015 HIAST Collegiate Programming Contest J. Polygons Intersection【计算几何求解两个凸多边形的相交面积板子题】

    J. Polygons Intersection time limit per test:2 seconds memory limit per test:64 megabytes input:stan ...

  9. Gym 100952H&&2015 HIAST Collegiate Programming Contest H. Special Palindrome【dp预处理+矩阵快速幂/打表解法】

    H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard ...

随机推荐

  1. 2016 Multi-University Training Contest 6 solutions BY UESTC

    A Boring Question \[\sum_{0\leq k_{1},k_{2},\cdots k_{m}\leq n}\prod_{1\leq j< m}\binom{k_{j+1}}{ ...

  2. CodeForces 597A Divisibility

    水题. #include<iostream> #include<cstring> #include<cmath> #include<queue> #in ...

  3. jree-创建普通折线图

    对于maven工程,需要引入依赖:在pom.xml中,添加如下内容 <dependency> <groupId>jfree</groupId> <artifa ...

  4. Maven+mybatis教程

    首先,配置maven 在eclipse中把maven路径和settings.xml文件配置好之后,否则后续会有一些问题 可以设一个环境变量M2_HOME指向你的maven安装目录 M2_HOME=G: ...

  5. 百亿级企业级 RPC 框架开源了!

    今天给大家介绍给一款性能卓越的 RPC 开源框架,其作者就是我推荐每个 Java 程序员都应该看的<Java 生态核心知识点整理>的原作者张玉龙. 说实话我第一次看到这个资料的时候,就感觉 ...

  6. IntelliJ IDEA 基本配置入门

    前言:今天下载安装IntelliJ IDEA.随手创建了一个项目,运行Build提示错误. 与大多数用于开发JAVA的IDE类似,不做不论什么配置.编译是不会成功的.因此我尝试对IDEA的配置进行了一 ...

  7. cocoapods应用第一部分-xcode创建.framework相关

    问题的提出: 随着项目的越来越大,可能会出现好几个团队共同维护一个项目的情况,比如:项目组A负责当中的A块,项目组B负责当中的B块.....这几块彼此之间既独立,也相互联系.对于这样的情况,能够採用约 ...

  8. ICONFONT在APP中的使用

    阿里IconFont平台 http://www.iconfont.cn/ 这里是阿里巴巴UED部门开发的IconFont平台,眼下阿里系的重量级产品都在使用,里面有非常多资源可供使用. 这里说说怎样在 ...

  9. 深入浅出AOP(一)

    动态代理实现AOP: AOP事实上非常早之前依照做出来了一些东西,之所以不敢说做出来了.是由于它是什么?怎么实现?做出来的东西是不是?先前一直查资料.查到的资料跟着做.到后来发现,AOP越来越大,而非 ...

  10. wsdl2objc定制(一)namespace

    1.问题抛出: 如今还是有非常多人使用 wsdl2objc 来调用webservice,可是有时候会有不开心的事情发生, <soap:Envelope xmlns:soap="http ...