Light OJ 1030 - Discovering Gold
题目大意:
- #include<cstdio>
- #include<cstring>
- #include<iostream>
- #include<algorithm>
- #include<cmath>
- #include<queue>
- #include<vector>
- #include<map>
- using namespace std;
- typedef long long LL;
- const int INF = 1e9+;
- const int MAXN = ;
- int n;
- double dp[MAXN], a[MAXN];
- ///dp[从i到达终点] = 期望
- double DFS(int cur)
- {
- if(dp[cur] != -)
- return dp[cur];
- int cnt = min(n-cur, );///代表当前格子可以向向前移动多少个位置
- dp[cur] = ;
- for(int i=cur+; i<=cur+cnt; i++)
- dp[cur] += 1.0/cnt * DFS(i);
- dp[cur] += a[cur];
- return dp[cur];
- }
- int main()
- {
- int T, cas = ;
- scanf("%d", &T);
- while(T --)
- {
- scanf("%d", &n);
- for(int i=; i<=n; i++)
- {
- scanf("%lf", &a[i]);
- dp[i] = -;
- }
- dp[n] = a[n];
- printf("Case %d: %.6lf\n", cas++, DFS());
- }
- return ;
- }
- /*
- 3
- 3
- 1 2 3
- */
Light OJ 1030 - Discovering Gold的更多相关文章
- Light OJ 1030 - Discovering Gold(概率dp)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1030 题目大意:有一个很长的洞穴, 可以看做是1-n的格子.你的起始位置在1的 ...
- LightOJ - 1030 Discovering Gold —— 期望
题目链接:https://vjudge.net/problem/LightOJ-1030 1030 - Discovering Gold PDF (English) Statistics For ...
- 1030 - Discovering Gold
1030 - Discovering Gold PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 M ...
- Light oj 1030 概率DP
D - Discovering Gold Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768 ...
- [LOJ 1030] Discovering Gold
B - Discovering Gold Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu ...
- LightOJ 1030 Discovering Gold(期望)
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...
- LightOj 1030 - Discovering Gold(dp+数学期望)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 题意:在一个1*n 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得 ...
- LightOJ 1030 Discovering Gold (概率/期望DP)
题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 ...
- light oj 1152 Hiding Gold
题目: You are given a 2D board where in some cells there are gold. You want to fill the board with 2 x ...
随机推荐
- Java——(六)Collection之Queue集合
------Java培训.Android培训.iOS培训..Net培训.期待与您交流! ------- Queue集合 Queue集合用于模拟队列这种数据结构,队列通常是指“先进先出‘(FIFO)的容 ...
- iOS UIKit:viewController之动画(5)
当弹出一个view controller时,UIKit提供了一些标准转换动画,并且也支持用户自定义的动画效果. 1 UIView动画 UIView是自带动画实现功能,其中有两种方式实现: ...
- transition的四个属性
transition-property 规定设置过渡效果的 CSS 属性的名称. transition-duration 规定完成过渡效果需要多少秒或毫秒. transition-timing-fun ...
- (九)打印机驱动设置—USB接口的设置
佳博打印机代理商淘宝店https://shop107172033.taobao.com/index.htm?spm=2013.1.w5002-9520741823.2.Sqz8Pf 在此店购买的打印机 ...
- JavaScript HTML DOM
JavaScript HTML DOM 通过 HTML DOM,可访问 JavaScript HTML 文档的所有元素. HTML DOM (文档对象模型) 当网页被加载时,浏览器会创建页面的文档对象 ...
- [转]Delphi I/O Errors
The following are the Windows API (and former DOS) IO errors, which are also the IO errors often ret ...
- 安装freebsd9 出现 mountroot>怎么办
之前手欠把linux分区给删了想重装freebsd 重新进入的时候mbr提示grub信息 用PE把MBR删掉 之后再用freebsd光盘启动出现mountroot> 就用mountroot> ...
- css学习--inline-block详解及dispaly:inline inline-block block 三者区别精要概括
*知识储备: 内联元素:是不可以控制宽和高.margin等:并且在同一行显示,不换行. 块级元素:是可以控制宽和高.margin等,并且会换行. 1.inline-block 详解 (1)一句话就是在 ...
- 干掉Google字体,WordPress速度暴涨
2014年7月7日23:40:31 因为Google被墙,WordPress引用的Google字体总会加载很长时间,严重影响打开速度. 安装WordPress插件 Disable Google Fon ...
- [前端笔记]第三篇:JavaScript
JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript语言的规则编写相应代码之,浏览器可以解释并做出相应的处理. 一.代码存放位置 J ...