#[allow(unused_imports)] use std::cmp::{max, min}; #[allow(unused_imports)] use std::collections::{HashMap, HashSet}; mod util { use std::io::stdin; use std::str::FromStr; use std::fmt::Debug; #[allow(dead_code)] pub fn line() -> String { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().to_string() } #[allow(dead_code)] pub fn get() -> T where ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() } #[allow(dead_code)] pub fn gets() -> Vec where ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse().unwrap()) .collect() } #[allow(dead_code)] pub fn get2() -> (T, U) where ::Err: Debug, ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } #[allow(dead_code)] pub fn get3() -> (S, T, U) where ::Err: Debug, ::Err: Debug, ::Err: Debug, { let mut line: String = String::new(); stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), iter.next().unwrap().parse().unwrap(), ) } } #[allow(unused_macros)] macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } } fn main() { let (f, n, k): (usize, usize, usize) = util::get3(); let mut e = 0.0; for m in 1..f + 1 { let mut dp = vec![vec![vec![0.0; k + 1]; k]; n + 1]; dp[0][0][0] = 1.0; for i in 1..n + 1 { for j in 0..k { for h in 0..k + 1 { if h >= 1 { dp[i][j][h] += dp[i - 1][j][h - 1] / f as f64; } if h == k { dp[i][j][h] += dp[i - 1][j][h] / f as f64; } if j >= 1 { dp[i][j][h] += dp[i - 1][j - 1][h] * ((f - m) as f64) / f as f64; } dp[i][j][h] += dp[i - 1][j][h] * ((m - 1) as f64) / f as f64; } } } for i in 0..k { for j in 0..k + 1 { if j >= k - i { e += m as f64 * dp[n][i][j]; } } } } println!("{}", e); }