2016 Multi-University Training Contest 5

时间:2023-01-11 22:01:57

6/12

2016 Multi-University Training Contest 5

期望+记忆化DP A ATM Mechine(BH)

题意:

  去ATM取钱,已知存款在[0,K]范围内,每一次输入取出钱的金额,如果大于存款,ATM会发出警报,最多W次,问能在W次内取出所有存款的取款次数的期望值。

思路:

  设dp[k][w]表示范围存款在[0,k]内,还有w次报警机会的期望值。状态转移方程:2016 Multi-University Training Contest 5

代码:

#include <bits/stdc++.h>

const int N = 2e3 + 5;
const int INF = 0x3f3f3f3f;
const int D = 16;
double dp[N][D];
bool vis[N][D]; double DP(int k, int w) {
if (k == 0) return 0;
if (w == 0) return INF;
if (vis[k][w]) return dp[k][w];
double &ret = dp[k][w] = INF;
for (int i=1; i<=k; ++i) {
ret = std::min (ret, DP (i-1, w-1)*i/(k+1) + DP (k-i, w)*(k-i+1)/(k+1) + 1);
}
vis[k][w] = true;
return ret;
} int main() {
int k, w;
while (scanf ("%d%d", &k, &w) == 2) {
printf ("%.6f\n", DP (k, std::min (w, 15)));
}
return 0;
}

  

2016 Multi-University Training Contest 5的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  3. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  4. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  5. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  6. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  7. 2016 Al-Baath University Training Camp Contest-1 G

    Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...

  8. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

  9. 2016 Al-Baath University Training Camp Contest-1 D

    Description X is well known artist, no one knows the secrete behind the beautiful paintings of X exc ...

  10. 2016 Al-Baath University Training Camp Contest-1 C

    Description Rami went back from school and he had an easy homework about bitwise operations (and,or, ...

随机推荐

  1. Unity3D 简单的倒计时

    using System; using UnityEngine; using System.Collections; public class TimeCountdown : MonoBehaviou ...

  2. FIJ Jobs – 2013&sol;8&sol;12

    Department Vacancies Total Skill Set Experience Language Systems Systems Coordinator 1 Communication ...

  3. 关于用phonegap&plus;jquery moblie开发 白屏闪屏的解决方法

    前几天自己玩开发android应用,做些页面切换效果时,发现两个页面间切换间有白色闪屏的问题. 在网上找了很久的资料,还是没有解决. 最终,发现同事开发的android应用没有这个问题.对比代码排除发 ...

  4. CodeForces 548A Mike and Fax &lpar;回文,水题&rpar;

    题意:给定一个字符串,问是不是恰好存在 k 个字符串是回文串,并且一样长. 析:没什么好说的,每次截取n/k个,判断是不是回文就好. 代码如下: #include<bits/stdc++.h&g ...

  5. &num;&num;&num;Git使用问题

    #@date: 2014-05-04 #@author: gerui #@email: forgerui@gmail.com 一.git reset的使用 今天修改了代码,就git add ./,添加 ...

  6. String、StringBuffer和StringBuild的区别

    public class Test1 { public static void stringReplace (String text) { text = text.replace('j','i') ; ...

  7. ZOJ 3723 &lpar;浙大月赛&rpar;状压DP

    A了一整天~~~终于搞掉了. 真是血都A出来了. 题目意思很清楚,肯定是状压DP. 我们可以联系一下POJ 1185  炮兵阵地,经典的状压DP. 两道题的区别就在于,这道题的攻击是可以被X挡住的,而 ...

  8. Runtime的使用

    一.RunTime简介 RunTime简称运行时.OC就是运行时机制,也就是在运行时候的一些机制,其中最主要的是消息机制. 对于C语言,函数的调用在编译的时候会决定调用哪个函数. 对于OC的函数,属于 ...

  9. 用solidity语言开发代币智能合约

    智能合约开发是以太坊编程的核心之一,而代币是区块链应用的关键环节,下面我们来用solidity语言开发一个代币合约的实例,希望对大家有帮助. 以太坊的应用被称为去中心化应用(DApp),DApp的开发 ...

  10. R语言中函数调试

    有时候会用R语言写一下简单的脚本处理函数,加入需要调试的话可以按照下面的步骤进行: fun <- function(x , y){ x + y x - y x * y x / y } debug ...