結果

問題 No.567 コンプリート
ユーザー phsplsphspls
提出日時 2023-01-07 01:10:45
言語 Rust
(1.77.0)
結果
AC  
実行時間 389 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 144,996 KB
実行使用メモリ 87,832 KB
最終ジャッジ日時 2023-08-20 18:21:05
合計ジャッジ時間 3,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 389 ms
87,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();

    let mut dp = vec![vec![0.; 7]; n+1];
    dp[1][1] = 1.;
    for i in 1..n {
        for j in 1..=6 {
            if dp[i][j] == 0. { continue; }
            dp[i+1][j] += dp[i][j] * j as f64 / 6.;
            if j+1 <= 6 {
                dp[i+1][j+1] += dp[i][j] * (6 - j) as f64 / 6.;
            }
        }
    }
    println!("{}", dp[n][6]);
}
0