/* 这题的dp思路挺巧妙,dp[i][j]记录当长度为i时,末位为j的,并且满足题目要求的,取法...并且还除以了截至该位,占所有排列的概率(每次更新dp,都有除以(1+k) ) 解析见: http://blog.csdn.net/codebattle/article/details/38420827 http://www.cnblogs.com/scau20110726/archive/2013/02/17/2914763.html */
#include <iostream> #include <iomanip> using namespace std; int k, n; const int MAXN = 110; const int MAXM = 15; double dp[MAXN][MAXM]; void solve() { for (int i = 0; i <= k; i++) dp[1][i] = 100.0 / (k + 1); for (int i = 2; i <= n; i++) for (int j = 0; j <= k; j++) { dp[i][j] = dp[i - 1][j] / (k + 1); if (j != 0) dp[i][j] += dp[i - 1][j - 1] / (k + 1); if (j != k) dp[i][j] += dp[i - 1][j + 1] / (k + 1); } double ans = 0; for (int i = 0; i <= k; i++) ans += dp[n][i]; cout << fixed << setprecision(5) << ans << endl; } int main() { while (cin >> k >> n) { solve(); } return 0; }