本篇是一个概率DP问题,也是DP专题的最后一篇,概率DP是DP中一个较为特殊的算法问题,混合了概率这个元素在里面,需要对概率有比较好的理解。
概率DP问题很多时候会和复杂的概率计算混合在一起,要想更好的掌握只能多做相关题目,熟练掌握概率相关的知识也是很重要的一步。
概况DP是混合了概率计算和DP结构的一种算法。
本篇是一个入门题目,希望能够让没接触过概率DP的同学有个简单了解。
Problem Description
Michael has a telecontrol robot. One day he put the robot on a loop with n cells. The cells are numbered from 1 to n clockwise.
麦克有一个遥控机器人,他把机器人放在一个圆盘上,圆盘分为n格,如下图所示,格子从1标记到n。
At first the robot is in cell 1. Then Michael uses a remote control to send m commands to the robot. A command will make the robot walk some distance. Unfortunately the direction part on the remote control is broken, so for every command the robot will chose a direction(clockwise o