fn main() { let n = get::val::(); let k = get::val::(); let t = Time::new(); let mut rand = XorShift::new(); let mut count = 0; let mut win = 0; while t.elapsed() < 4.9 { let taro: u64 = (0..n-k).map(|_|rand.from_to(1,6)).sum::() + (0..k).map(|_|rand.from_to(4,6)).sum::(); let jiro: u64 = (0..n).map(|_|rand.from_to(1,6)).sum::(); if taro > jiro {win += 1} count += 1 } println!("{}", win as f64 / count as f64) } use std::time::*; struct Time { start: Instant } #[allow(dead_code)] impl Time { fn new() -> Time { Time {start: Instant::now()} } fn elapsed(&self) -> f64 { let sec = self.start.elapsed().as_secs() as f64; let nano = self.start.elapsed().subsec_nanos() as f64 / 1000000000.0; sec + nano } } #[derive(Copy, Clone)] struct XorShift { state1: u64, state2: u64 } #[allow(dead_code)] impl XorShift { fn new() -> XorShift { use std::time::*; let start = Instant::now(); let seed1 = start.elapsed().subsec_nanos() as u64; let seed2 = start.elapsed().subsec_nanos() as u64; XorShift {state1: seed1, state2: seed2} } fn next(&mut self) -> u64 { let mut s1 = self.state2; let mut s2 = self.state1; s1 = s1 ^ (s1 >> 26); s2 = s2 ^ (s2 << 23); s2 = s2 ^ (s2 >> 17); self.state1 = self.state2; self.state2 = s1 ^ s2; (self.state1 >> 1) + (self.state2 >> 1) } fn from_to(&mut self, from: u64, to: u64) -> u64 { self.next() % (to - from + 1) + from } } #[allow(dead_code)] mod get { use std::io::*; use std::str::*; pub fn val() -> T { let mut buf = String::new(); let s = stdin(); s.lock().read_line(&mut buf).ok(); buf.trim_right().parse::().ok().unwrap() } pub fn vals(n: usize) -> Vec { let mut vec: Vec = vec![]; for _ in 0 .. n { vec.push(val()); } vec } pub fn tuple() -> (T1, T2) { let mut buf = String::new(); let s = stdin(); s.lock().read_line(&mut buf).ok(); let mut it = buf.trim_right().split_whitespace(); let x = it.next().unwrap().parse::().ok().unwrap(); let y = it.next().unwrap().parse::().ok().unwrap(); (x, y) } pub fn tuples(n: usize) -> Vec<(T1, T2)> { let mut vec: Vec<(T1, T2)> = vec![]; for _ in 0 .. n { vec.push(tuple()); } vec } pub fn tuple3() -> (T1, T2, T3) { let mut buf = String::new(); let s = stdin(); s.lock().read_line(&mut buf).ok(); let mut it = buf.trim_right().split_whitespace(); let x = it.next().unwrap().parse::().ok().unwrap(); let y = it.next().unwrap().parse::().ok().unwrap(); let z = it.next().unwrap().parse::().ok().unwrap(); (x, y, z) } pub fn tuple3s(n: usize) -> Vec<(T1, T2, T3)> { let mut vec: Vec<(T1, T2, T3)> = vec![]; for _ in 0 .. n { vec.push(tuple3()); } vec } pub fn list() -> Vec { let mut buf = String::new(); let s = stdin(); s.lock().read_line(&mut buf).ok(); buf.trim_right().split_whitespace().map(|t| t.parse::().ok().unwrap()).collect() } pub fn lists(h: usize) -> Vec> { let mut mat: Vec> = vec![]; for _ in 0 .. h { mat.push(list()); } mat } pub fn chars() -> Vec { let mut buf = String::new(); let s = stdin(); s.lock().read_line(&mut buf).ok(); buf.trim_right().chars().collect() } }