結果

問題 No.75 回数の期待値の問題
ユーザー tonyu0tonyu0
提出日時 2020-03-30 21:47:16
言語 Rust
(1.77.0)
結果
AC  
実行時間 65 ms / 5,000 ms
コード長 815 bytes
コンパイル時間 3,136 ms
コンパイル使用メモリ 137,032 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 08:07:04
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

use std::io::*;

fn rand() -> u32 {
    static mut X: u32 = 123456789;
    static mut Y: u32 = 362436069;
    static mut Z: u32 = 521288629;
    static mut W: u32 = 88675123;
    unsafe {
        let t = X ^ (X << 11);
        X = Y;
        Y = Z;
        Z = W;
        W = (W ^ (W >> 19)) ^ (t ^ (t >> 8));
        W
    }
}

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: u32 = itr.next().unwrap().parse().unwrap();

    let mut ans = 0.0;
    for _ in 0..100000 {
        let mut now = 0u32;
        while now != k {
            now += rand() % 6 + 1;
            if now > k {
                now = 0;
            }
            ans += 1.0;
        }
    }
    println!("{:.10}", ans / 100000.0);
}
0