2489. Honeycomb Walk

一次性AC,此问题为动态规划的问题,题意为一直蜜蜂在一个六角形的格子里面,它向其临近的六边形走都有可能,给定一个N,让蜜蜂在走N步后还是回到起始的格子里面,问有多少种解法。用动态规划的问题解决。将六角形抽象到坐标轴中,用三维数组dp[k][i][j]来表示,其中k为达到(i,j)这个点所用的步数,由于k<=14,故蜜蜂不能走出距离其大于7个格子,因为最终要回到原点,令(8,8)为起始地点,dp[k][8][8]代表走k步后回到原点的走法数量,即为我们要求得的数据。用关于k的循环一层层求。

A bee larva living in a hexagonal cell of a large honeycomb decides to creep for a walk. In each "step" the larva may move into any of the six adjacent cells and after n steps, it is to end up in its original cell.

Your program has to compute, for a given n, the number of different such larva walks.

Input specifications

The first line contains an integer giving the numb


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部