結果
問題 |
No.75 回数の期待値の問題
|
ユーザー |
|
提出日時 | 2020-03-30 21:47:16 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 63 ms / 5,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 13,377 ms |
コンパイル使用メモリ | 378,876 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 04:13:42 |
合計ジャッジ時間 | 14,847 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
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); }