結果

問題 No.75 回数の期待値の問題
ユーザー tonyu0tonyu0
提出日時 2020-04-03 00:19:00
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 146,076 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 00:55:41
合計ジャッジ時間 1,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let k: usize = itr.next().unwrap().parse().unwrap();

    // 勝手に収束する・・
    let mut dp: Vec<f64> = vec![0.0; k + 1];

    for _ in 0..50 {
        for i in 1..k + 1 {
            dp[i] = 1.0;
            for j in 1..7 {
                if i < j {
                    dp[i] += dp[k] / 6.0;
                } else {
                    dp[i] += dp[i - j] / 6.0;
                }
            }
        }
    }
    println!("{}", dp[k]);
}
0