結果
| 問題 | No.567 コンプリート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-11 09:42:09 |
| 言語 | Rust (1.92.0 + proconio + num) |
| 結果 |
AC
|
| 実行時間 | 437 ms / 2,000 ms |
| コード長 | 1,720 bytes |
| 記録 | |
| コンパイル時間 | 12,219 ms |
| コンパイル使用メモリ | 379,416 KB |
| 実行使用メモリ | 87,916 KB |
| 最終ジャッジ日時 | 2024-12-14 15:53:48 |
| 合計ジャッジ時間 | 13,532 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 |
ソースコード
#[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: FromStr>() -> T
where
<T as FromStr>::Err: Debug,
{
let mut line: String = String::new();
stdin().read_line(&mut line).unwrap();
line.trim().parse().unwrap()
}
#[allow(dead_code)]
pub fn gets<T: FromStr>() -> Vec<T>
where
<T as FromStr>::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: FromStr, U: FromStr>() -> (T, U)
where
<T as FromStr>::Err: Debug,
<U as FromStr>::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(),
)
}
}
fn main() {
let n: usize = util::get();
let mut dp = vec![vec![0.0; 7]; n + 1];
dp[0][0] = 1.0;
for i in 1..n + 1 {
for k in 1..7 {
dp[i][k] += dp[i - 1][k - 1] * (6 - k + 1) as f64 / 6.0;
dp[i][k] += dp[i - 1][k] * k as f64 / 6.0;
}
}
println!("{}", dp[n][6]);
}