Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

又 1A 了,好高兴啊 - - - - - -

Posted by shu_mj at 2014-08-03 00:52:11 on Problem 1322
贴一个关键部分代码:

    private void solve(int c, int n, int m) {
        if (m < 0 || m > c) { out.println("0.000"); return ; }
        double[][] mat = new double[c + 1][c + 1];
        for (int j = 0; j <= c; j++) {
            if (j > 0) mat[j - 1][j] = (c - j + 1.0) / c;
            if (j < c) mat[j + 1][j] = (j + 1.0) / c;
        }
        double[][] ini = new double[c + 1][c + 1];
        ini[0][0] = 1;
        mat = Matrix.pow(mat, n);
        out.printf("%.3f%n", Matrix.mul(ini, mat)[0][m]);
    }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator