#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; // 行列の積 template vector > matrixProduct(const vector >& x, const vector >& y) { int a = x.size(); int b = x[0].size(); int c = y[0].size(); vector > z(a, vector(c, 0)); for(int i=0; i vector > matrixPower(const vector >& x, int k) { int n = x.size(); vector > y(n, vector(n, 0)); for(int i=0; i > z = x; while(k > 0){ if(k & 1) y = matrixProduct(y, z); z = matrixProduct(z, z); k >>= 1; } return y; } int main() { int p0, q; cin >> p0 >> q; vector > mat(102, vector(102, 0.0)); mat[101][101] = 1.0; for(int p=0; p<=100; ++p){ mat[p][101] += p / 100.0 * (1.0 / 2.0) + (100 - p) / 100.0 * (1.0 / 3.0); mat[p][max(0, p-q)] += p / 100.0 * (1.0 / 2.0); mat[p][min(100, p+q)] += (100 - p) / 100.0 * (1.0 / 3.0); } mat = matrixPower(mat, 100000000); double ans = 1.0 / 3.0 * (1 + mat[p0][101]); printf("%.10f\n", ans); return 0; }