lightoj 1030】的更多相关文章

题目链接:LightOJ - 1030 Description You are in a cave, a long cave! The cave can be represented by a \(1 \times N\) grid. Each cell of the cave can contain any amount of gold. Initially you are in position \(1\). Now each turn you throw a perfect \(6\) s…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; ; const int INF = 0x3f3f3f3f; double dp[maxn]; int a[maxn]; int main() { //f…
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfect 6 sided dice. If you get X in the dice a…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 题意:在一个1*n 的格子里,每个格子都有相应的金币数,走到相应格子的话,就会得到该格子的金币.  现在有一个人在1这个位置,手里有一颗骰子,骰子摇到几,他就前进几步,但如果当前位置+骰子数 > n,那么他就会重新摇色子一直到<=n为止. 走到n这个位置的话,意味着游戏结束了. 问游戏结束时,这个人得到金币的期望. 设dp[i]表示从i号格子出去的期望,所以dp[i]是和i后…
题目链接:https://vjudge.net/problem/LightOJ-1030 1030 - Discovering Gold    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can…
正推,到达i的概率为p[i],要注意除了1和n外,到达i的概率并不一定为1 概率表达式为p[i] += p[j] / min(n - j, 6) 从j带过来的期望为exp[i] += exp[j] / min(n - j, 6) 又到达i时有价值val[i],到达i的概率为p[i],故exp[i] += val[i] * p[i] #include<cstdio> #include<iostream> #include<cstdlib> #include<cstr…
题意:有一个迷宫是1×n的格子,一个人每到一个格子就能够把这个格子内的金子所有拿走,刚開始站在第1个格子,然后開始掷骰子得到点数x,他就要从当前位置走到加x的位置.假设发现位置是大于n的就又一次掷骰子直到符合,假设他到了第n个格子就能够结束了. 问这个人从迷宫里得到的金子的期望是多少. 题解:能够知道对于每一个位置.下一个位置仅仅能是后6个.所以从这个位置处得到的金子的期望f(i) = (f(i + 1) + f(i + 2) + - + f(i + 6)) / 6.假设这个位置后不足6.f(i…
You are x N grid. Each cell of the cave can contain any amount of gold. Initially you are . Now each turn you sided dice. If you get X in the dice after throwing, you add X to your position and collect all the gold from the new position. If your new…
递推,倒着递推. #include<stdio.h> #define maxn 1010 #define min(a,b) (a)>(b)?(b):(a) int main() { ; int a[maxn]; double f[maxn]; scanf("%d",&T); while(T--) { scanf("%d",&n); ;i<=n;i++) scanf("%d",&a[i]); f[n]…
期望,$dp$. 设$ans[i]$为$i$为起点,到终点$n$获得的期望金币值.$ans[i]=(ans[i+1]+ans[i+2]+ans[i+3]+ans[i+4]+ans[i+5]+ans[i+6])/6+a[i]$,不到$6$个的单独处理一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cm…