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

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

就简单了。

代码如下:

  1. #pragma comment(linker, "/STACK:1024000000,1024000000")
  2. #include <cstdio>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <cmath>
  6. #include <iostream>
  7. #include <cstring>
  8. #include <set>
  9. #include <queue>
  10. #include <algorithm>
  11. #include <vector>
  12. #include <map>
  13. #include <cctype>
  14. #include <cmath>
  15. #include <stack>
  16. //#include <tr1/unordered_map>
  17. #define freopenr freopen("in.txt", "r", stdin)
  18. #define freopenw freopen("out.txt", "w", stdout)
  19. using namespace std;
  20. //using namespace std :: tr1;
  21.  
  22. typedef long long LL;
  23. typedef pair<int, int> P;
  24. const int INF = 0x3f3f3f3f;
  25. const double inf = 0x3f3f3f3f3f3f;
  26. const LL LNF = 0x3f3f3f3f3f3f;
  27. const double PI = acos(-1.0);
  28. const double eps = 1e-8;
  29. const int maxn = 1e4 + 5;
  30. const LL mod = 10000000000007;
  31. const int N = 1e6 + 5;
  32. const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
  33. const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
  34. const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
  35. inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
  36. int n, m;
  37. const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  38. const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  39. inline int Min(int a, int b){ return a < b ? a : b; }
  40. inline int Max(int a, int b){ return a > b ? a : b; }
  41. inline LL Min(LL a, LL b){ return a < b ? a : b; }
  42. inline LL Max(LL a, LL b){ return a > b ? a : b; }
  43. inline bool is_in(int r, int c){
  44. return r >= 0 && r < n && c >= 0 && c < m;
  45. }
  46. int s, t;
  47. double p, q;
  48.  
  49. double dfs(int time, int s){
  50. if(s >= n) return 1.0;
  51. if(s <= 0) return 0.0;
  52. if(time <= 0) return 0.0;
  53.  
  54. double ans = 0.0;
  55. ans += dfs(time - 1, s + min(s, n-s)) * p;
  56. ans += dfs(time - 1, s - min(s, n-s)) * q;
  57. return ans;
  58. }
  59.  
  60. int main(){
  61. freopen("betting.in", "r", stdin);
  62. freopen("betting.out", "w", stdout);
  63. while(scanf("%d %d %lf %d", &n, &s, &p, &t) == 4 && n){
  64. p /= 100.0; q = 1.0 - p;
  65. double ans = dfs(t, s);
  66. printf("%.10f\n", ans);
  67. }
  68. return 0;
  69. }

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. 网络安全法与LogSec日志安全大数据审计平台

    https://blog.csdn.net/chengpeng1144/article/details/73555331 https://blog.csdn.net/dcbeyond/article/ ...

  2. Tell me the area---hdu1798 (数学 几何)

    http://acm.hdu.edu.cn/showproblem.php?pid=1798 给你两个圆求阴影部分的面积 求出两个扇形的面积减去四边形的面积 扇形的面积是度数(弧度制)*半径的平方 不 ...

  3. service mesh架构

    service  mesh 系列文章 https://my.oschina.net/iamlipeng/blog/1631575 http://developer.51cto.com/art/2018 ...

  4. 关于maven多个模块的build顺序 [INFO] Reactor Build Order

    对于一个maven项目,如果有多个模块,那么它们的执行顺序是什么样的呢? 在执行mvn操作的时候,你可以看到如下信息,这个便是maven的build顺序 那么maven是如何决定顺序的呢?如下: 在多 ...

  5. InfluxDB useful commands

    InfluxDB 配置文件地址:/etc/influxdb/influxdb.conf 通过curl写数据 curl -i -XPOST 'http://localhost:8086/write?db ...

  6. c++多线程编程:常见面试题

    题目:子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次,如此循环50次,试写出代码 子线程与主线程必有一个满足条件(flag == ...

  7. ES文件浏览器 WIFI 查看电脑文件怎么弄

    1 开启来宾账户   2 右击要共享的文件夹,添加Guest共享(如果只是要查看共享的资源,权限级别为读取即可)   3 共享之后,网络路径就是"\\"+你的计算机名+" ...

  8. Deepin-我为什么推荐它!

    针对Win上的开发软件,大部分都需要密匙或者破解,而Deepin不敢说一应俱全,但全沾边是没问题的 无论是编程.娱乐还是其它的,基本上都可以做到,而且它还应用了Crossover来兼容大部分的Win软 ...

  9. Zookeeper 3.4 官方文档翻译

    说明 个人英语水平非常一般,理解可能有偏差,假设有翻译不恰当之处,请看官指点. 1.简单介绍 分布式系统就像动物园.当中每台server就像一仅仅动物,Zookeeper就像动物园管理员,协调.服务于 ...

  10. 在Oracle数据库中使用NFS,怎样调优?

    MOS上有好多文章,基本上都跑不了以下三点: Setup can make a big difference 1. Network topology and load 2. NFS mount opt ...