HDU 4418 Time travel】的更多相关文章

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4418 Time travel Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 Agent K is one of the greatest agents in a secret organization called Men in Black. Once he needs to…
Time travel http://acm.hdu.edu.cn/showproblem.php?pid=4418 分析: 因为走到最后在折返,可以将区间复制一份,就变成了只往右走,012343210. 写出转移方程: $f[t] = 0$ $f[i] = p_1 \times (f[i +1] + 1) + p_2 \times (f[i +2] + 2) + \cdots$ $ =\sum\limits_{j=1}^{m}p_j \times (f[i + j] + j) $ $= \su…
Time travel Problem Description Agent K is one of the greatest agents in a secret organization called Men in Black. Once he needs to finish a mission by traveling through time with the Time machine. The Time machine can take agent K to some point (0…
高斯消元求期望!! 将n时间点构成2*(n-1)的环,每一点的期望值为dp[i]=dp[i+1]*p1+dp[i+2]*p2+……+dp[i+m]*pm+1. 这样就可以多个方程,利用高斯消元求解. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #inc…
http://acm.hdu.edu.cn/showproblem.php?pid=4418 题意:一个0-n-1的坐标轴,给出起点X.终点Y,和初始方向D(0表示从左向右.1表示从右向左,-1表示起点或终点),在走的过程中如果到达起点或终点,那么下一步往反方向走.每次可以走1-m步,每步概率为p[i],问走到终点的期望步数.(n,m,X,Y<=100) #include <cstdio> #include <algorithm> #include <cstring&g…
Agent K is one of the greatest agents in a secret organization called Men in Black. Once he needs to finish a mission by traveling through time with the Time machine. The Time machine can take agent K to some point (0 to n-1) on the timeline and when…
对于每个点两个方向(两头只有一个方向)建一个点,然后预处理出每个点走k(1≤k≤n)k(1\le k\le n)k(1≤k≤n)到哪个点,列出方程式高斯消元就行了.记得前面bfsbfsbfs出那些点不可到,他们的期望没有意义. 方程式比较显然: E[i]=∑k=1mpk∗(E[to(i,k)]+k)E[i]=\sum_{k=1}^mp_k*(E[to(i,k)]+k)E[i]=k=1∑m​pk​∗(E[to(i,k)]+k) (to(i,k)to(i,k)to(i,k)表示iii点走kkk步到的…
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pid=4418 读了一遍题后大体明白意思,但有些细节不太确定.就是当它处在i点处,它有1~m步可以走,但他走的方向不确定呢.后来想想这个方向是确定的,就是他走到i点的方向,它会继续朝着这个方向走,直到转向回头. 首先要解决的一个问题是处在i点处,它下一步该到哪个点.为了解决方向不确定的问题,将n个点转…
1. 题目描述K沿着$0,1,2,\cdots,n-1,n-2,n-3,\cdots,1,$的循环节不断地访问$[0, n-1]$个时光结点.某时刻,时光机故障,这导致K必须持续访问时间结点.故障发生在结点x处,方向为d,在访问k个结点后时光机以概率$P_k%$的概率修复好,k不超过m.求当K最终访问结点Y时经过的时光结点的期望. 2. 基本思路上述循环节包含包含$nn = 2n-2个$元素(因此,尤其需要特判n=1的情况,否则除0wa).通过x和方向d可以唯一的确定x在这个循环节中的位置.设$…
Time travel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1480    Accepted Submission(s): 327 Problem Description Agent K is one of the greatest agents in a secret organization called Men in B…