結果
| 問題 |
No.65 回数の期待値の練習
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-30 21:38:51 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 750 bytes |
| コンパイル時間 | 11,764 ms |
| コンパイル使用メモリ | 382,824 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 03:59:52 |
| 合計ジャッジ時間 | 12,831 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
ans += 1.0;
}
}
println!("{:.10}", ans / 100000.0);
}