很简单的概率题了

设dp[x]为能力值 为x时出去的期望 天数

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
double dp[20005];
int ci[125];
double is=0.5*(1+sqrt(5));
int main(){
int n,f,ma;
while(scanf("%d%d",&n,&f)!=EOF){
ma=-1;
for(int i=1;i<=n;i++){
scanf("%d",&ci[i]);
ma=max(ma,ci[i]);
}
ma=ma*2;
for(int i=max(ma,f);i>=f;i--){
dp[i]=0;
for(int k=1;k<=n;k++){
if(i>ci[k]) dp[i]+=(int)(is*ci[k]*ci[k]);
else{
dp[i]+=(dp[i+ci[k]]+1);
}
}
dp[i]=(dp[i])/n;
}
printf("%.3lf\n",dp[f]);
}
return 0;
}

  

ZOJ 3640的更多相关文章

  1. Help Me Escape (ZOJ 3640)

    J - Help Me Escape Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB ...

  2. 概率dp ZOJ 3640

    Help Me Escape Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit ...

  3. ZOJ 3640 Help Me Escape:期望dp

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3640 题意: 有一个吸血鬼被困住了,他要逃跑... 他面前有n条 ...

  4. zoj 3640 Help Me Escape 概率DP

    记忆化搜索+概率DP 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include ...

  5. Help Me Escape ZOJ - 3640

    Background     If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth ...

  6. zoj 3640 概率dp

    题意:一只吸血鬼,有n条路给他走,每次他随机走一条路,每条路有个限制,如果当时这个吸血鬼的攻击力大于等于某个值,那么就会花费t天逃出去,否则,花费1天的时间,并且攻击力增加,问他逃出去的期望 用记忆化 ...

  7. zoj 3640 Help Me Escape (概率dp 递归求期望)

    题目链接 Help Me Escape Time Limit: 2 Seconds      Memory Limit: 32768 KB Background     If thou doest w ...

  8. 概率DP

    POJ 3744 Scout YYF I 这就是一个乱搞题,暴力发现TLE了,然后看了看discuss里说可以矩阵加速,想了一会才想明白怎么用矩阵,分着算的啊.先算f[num[i]-1]之类的,代码太 ...

  9. 概率dp专场

    专题链接 第一题--poj3744 Scout YYF I  链接 (简单题) 算是递推题 如果直接推的话 会TLE 会发现 在两个长距离陷阱中间 很长一部分都是重复的 我用 a表示到达i-2步的概率 ...

随机推荐

  1. Hadoop集群(第13期)_HBase 常用Shell命令

    进入hbase shell console$HBASE_HOME/bin/hbase shell如果有kerberos认证,需要事先使用相应的keytab进行一下认证(使用kinit命令),认证成功之 ...

  2. M​a​y​a​ ​2​0​1​2​ ​破​解​安​装​全​图​文​教​程

    在学习U3D的过程中.我们要用到Maya这个工具,(当然你也能够用其它类似的), 我在安装破解 Maya 2012 的过程其中,走了一些弯路.通过搜索发现,网上关于Maya 破解的文章大多语焉不详,为 ...

  3. [Preference] How to avoid Forced Synchronous Layout or FSL to improve site preference

    When tigger site updates the layout, it always follow this order: Javascript trigger style changes, ...

  4. [HTML 5] Styling with ARIA

    See if you can do a better job styling this button using ARIA states. One huge benefit to styling wi ...

  5. 图像算法研究---Adaboost算法具体解释

    本篇文章先介绍了提升放法和AdaBoost算法.已经了解的可以直接跳过.后面给出了AdaBoost算法的两个样例.附有详细计算过程. 1.提升方法(来源于统计学习方法) 提升方法是一种经常使用的统计学 ...

  6. Nagios监控nginx服务具体过程

    1在nginx 服务器上安装nrpe客户端: Nginx的服务须要监控起来.不然万一down了而不及时修复,会影响web应用.例如以下web应用上面启动的nginx后台进程[root@lb-net-2 ...

  7. BZOJ 4027: [HEOI2015]兔子与樱花 贪心

    4027: [HEOI2015]兔子与樱花 Description 很久很久之前,森林里住着一群兔子.有一天,兔子们突然决定要去看樱花.兔子们所在森林里的樱花树很特殊.樱花树由n个树枝分叉点组成,编号 ...

  8. win10中让Visual Studio默认使用Administrator权限运行

    https://stackoverflow.com/questions/9654833/how-to-run-visual-studio-as-administrator-by-default Win ...

  9. 【POJ 1704】 Georgia and Bob

    [题目链接] http://poj.org/problem?id=1704 [算法] 阶梯博弈 [代码] #include <algorithm> #include <bitset& ...

  10. Flask-上传文件和访问上传的文件

     1.1.上传文件和访问上传的文件 upload_file_demo.py from flask import Flask,request,render_template import os from ...