#include<cstdio>//wrong_codes #include<algorithm> using namespace std; ],anss; ],T,TT,n,endd; int main() { int i,j; scanf("%d",&T); ;TT<=T;TT++) { scanf("%d",&n); ;i<=n;i++) scanf("%d",&a[i]); ;i…
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 after throwin…
题目链接: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…
一排1到n的格子,每个格子上有黄金 ai ,你最开始在 1 号,每一次投骰子决定到哪一个格子,超出1~n范围则重新投掷,你到了哪个格子就得到哪个格子的金币,问最终在n 能得到金币的期望. 思路:做题经验,期望都是从后推到前,我们从最大开始dp, 1~6  种情况的传递,但是当前面的格子数少于6的时候需要特判: #include<cstdio> #include<algorithm> #include<math.h> #include<string.h> #i…
A Dangerous Maze (II) LightOJ - 1395(概率dp) 这题是Light Oj 1027的加强版,1027那道是无记忆的. 题意: 有n扇门,每次你可以选择其中一扇.xi为负值的门带你abs(xi)后又回到原点.xi为正值 的门则带你离开迷宫,并且你会记住你前面选择的K道门,在下次选择的时候不会选择这些门.选择每扇门的概率相等.求走出迷宫的时间期望值. 题解: \(定义E[i] 表示记住了K道门后,显然这K道门都是为负值的门,走出迷宫的时间期望值,sum1表示为正的…
Where to Run LightOJ - 1287(概率dp) 题面长长的,看了半天也没看懂题意 不清楚的地方,如何判断一个点是否是EJ 按照我的理解 在一个EJ点处,要么原地停留五分钟接着走,要么直接走,但是这样样例都对不上 mmp,原来是说,在原地停留五分钟后再继续这两种选择 而且题目问的是 求被警察抓的期望时间,实际上却是求遍历完整张图的期望时间,也就是说总是会走是EJ的点 对于每个点来说从该点出发的期望时间\(dp[i] = \frac{dp[i]+5}{cnt+1} + \frac…
D - Discovering Gold Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1030 Description You are in a cave, a long cave! The cave can be represented by a 1…
概率dp+高斯消元 https://vjudge.net/problem/LightOJ-1151 题意:刚开始在1,要走到100,每次走的距离1-6,超过100重来,有一些点可能有传送点,可以传送到前面或后面,那么概率dp没法递推,只能高斯消元 设期望E(x),首先100这个位置的期望E(100)=0,然后可以找出方程, 对于传送点,E(x)=E(go(x)),对于非传送点,E(x)=(E(x+1)+E(x+2)+E(x+3)+E(x+4)+E(x+5)+E(x+6)+6)/cnt(cnt是可…
题意:给一个数n,每次除它的一个因子(等概率),问除到1的次数的期望是多少 题解:概率dp,对于一个数x,y是x的因子个数,因子是a1到ay,E(x)=(E(a1)+1)/y+...+(E(ay)+1)/y,复杂度O(nsqrt(n)) #include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define pi acos(-1.0) #define…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1030 思路:一直以来对这种概率题都挺感冒的=.=......还是说一下思路吧,dp[i]表示前i个位置所能能到的期望值,然后我们可以从后往前递推. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath>…