Help Me Escape (ZOJ 3640)
Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Description
Background
    If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him. 
     And Cain talked with Abel his brother: and it came to pass, when they were in the field, that Cain rose up against Abel his brother, and slew him. 
     And the LORD said unto Cain, Where is Abel thy brother? And he said, I know not: Am I my brother's keeper? 
     And he said, What hast thou done? the voice of thy brother's blood crieth unto me from the ground. 
     And now art thou cursed from the earth, which hath opened her mouth to receive thy brother's blood from thy hand; 
     When thou tillest the ground, it shall not henceforth yield unto thee her strength; a fugitive and a vagabond shalt thou be in the earth. 
—— Bible Chapter 4
Now Cain is unexpectedly trapped in a cave with N paths. Due to LORD's punishment, all the paths are zigzag and dangerous. The difficulty of the ith path is ci.
Then we define f as the fighting capacity of Cain. Every day, Cain will be sent to one of the N paths randomly.
Suppose Cain is in front of the ith path. He can successfully take ti days to escape from the cave as long as his fighting capacity f is larger than ci. Otherwise, he has to keep trying day after day. However, if Cain failed to escape, his fighting capacity would increase ci as the result of actual combat. (A kindly reminder: Cain will never died.)
As for ti, we can easily draw a conclusion that ti is closely related to ci. Let's use the following function to describe their relationship:

After D days, Cain finally escapes from the cave. Please output the expectation of D.
Input
The input consists of several cases. In each case, two positive integers N and f (n ≤ 100, f ≤ 10000) are given in the first line. The second line includes N positive integers ci (ci ≤ 10000, 1 ≤ i ≤ N)
Output
For each case, you should output the expectation(3 digits after the decimal point).
Sample Input
3 1
1 2 3
Sample Output
6.889 概率dp
求期望,记忆化搜索
#include <cstdio>
#include <cmath>
#include <cstring>
#define N 105
#define M 2500000
double f, c[N], t[N], p[M];
int n;
double dp(int ff)
{
if(p[ff] > 0.0) return p[ff];
for(int i = ; i < n; i++)
if(ff > c[i]) p[ff] += t[i] / (double)n;
else p[ff] += (1.0 + dp(ff + c[i])) / (double)n;
return p[ff];
} int main()
{
while(~scanf("%d%lf", &n, &f))
{
memset(p, , sizeof(p));
for(int i = ; i < n; i++) {
scanf("%lf", &c[i]);
t[i] = floor((1.0 + sqrt(5.0)) * c[i] * c[i] / 2.0);
}
printf("%.3lf\n", dp(f));
}
return ; }
Help Me Escape (ZOJ 3640)的更多相关文章
- HDU 3533 Escape(大逃亡)
		
HDU 3533 Escape(大逃亡) /K (Java/Others) Problem Description - 题目描述 The students of the HEU are maneu ...
 - POJ 1274 The Perfect Stall || POJ 1469 COURSES(zoj 1140)二分图匹配
		
两题二分图匹配的题: 1.一个农民有n头牛和m个畜栏,对于每个畜栏,每头牛有不同喜好,有的想去,有的不想,对于给定的喜好表,你需要求出最大可以满足多少头牛的需求. 2.给你学生数和课程数,以及学生上的 ...
 - 2014 牡丹江现场赛 A.Average Score(zoj 3819) 解题报告
		
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 题目意思: 有两个class:A 和 B,Bob 在 Clas ...
 - HDU 3533 Escape(BFS+预处理)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3533 题目大意:给你一张n* m的地图,人在起点在(0,0)要到达终点(n,m)有k(k<=10 ...
 - 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-I ( ZOJ 3827 ) Information Entropy
		
Information Entropy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Information ...
 - POJ 1595 Prime Cuts (ZOJ 1312) 素数打表
		
ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=312 POJ:http://poj.org/problem?id=159 ...
 - POJ 2590 Steps (ZOJ 1871)
		
http://poj.org/problem?id=2590 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1871 题目大 ...
 - POJ 1065 Wooden Sticks(zoj 1025) 最长单调子序列
		
POJ :http://poj.org/problem?id=1065 ZOJ: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId= ...
 - Escape (BFS + 模拟)
		
Problem Description The students of the HEU are maneuvering for their military training. The red arm ...
 
随机推荐
- 情报收集:Metasploit命令、查询网站和测试网站
			
外围信息收集: testfire.com IBM建立的测试网站 http://www.maxmind.com 查找一些网站的地理位置 http://searchdns.netcraft.com/ 查询 ...
 - [数据结构与算法]栈Stack的多种实现
			
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
 - hdu 4946 Area of Mushroom(凸包)
			
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 Area of Mushroom Time Limit: 2000/1000 MS (Java/Ot ...
 - Codeforces Round #158 (Div. 2) C. Balls and Boxes 模拟
			
C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
 - s表达式和json表达式
			
s表达式 + 1 2 3普通表达式 1+2+3json表达式{ +:[1, 2, 3]}优点,一个运算符,无限个参数 s表达式 * (+ 1 2) 3普通表达式 1+(2*3)json表达式{ *:[ ...
 - [转] Git SSH Key 生成步骤
			
Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置. github的SSH配置如下: 一 . 设置Git的user name和email: $ git ...
 - Nginx反向代理负载均衡
			
环境准备: 总共四台机器,两台装有Nginx的机器做负载均衡,两台机器装有Apache作为WEB服务器. 机器信息 hostname IP 说明 lb01 192.168.1.19 nginx主负载均 ...
 - 【Todo】【读书笔记】大数据Spark企业级实战版 & Scala学习
			
下了这本<大数据Spark企业级实战版>, 另外还有一本<Spark大数据处理:技术.应用与性能优化(全)> 先看前一篇. 根据书里的前言里面,对于阅读顺序的建议.先看最后的S ...
 - hdu 5476 Explore Track of Point(2015上海网络赛)
			
题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...
 - 发现easyui-accordion一个bug,在ie6、ie7不兼容性问题
			
当设置全局css文件单元格样式为下面时 td{ word-break: break-all; word-wrap: break-word;} easyui-accordion在ie6.ie7上面会出现 ...