結果
問題 |
No.287 場合の数
|
ユーザー |
|
提出日時 | 2016-06-23 16:01:03 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,428 bytes |
コンパイル時間 | 12,277 ms |
コンパイル使用メモリ | 378,740 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 00:21:57 |
合計ジャッジ時間 | 13,354 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::*; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); return ret; } fn get_word() -> String { let mut stdin = std::io::stdin(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin.read(&mut u8b); if res.is_err() || u8b[0] <= ' ' as u8 { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = std::string::String::from_utf8(buf).unwrap(); return ret; } } } fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() } #[allow(dead_code)] fn get<T: std::str::FromStr>() -> T { parse(&get_word()) } fn square(poly: &[i64]) -> Vec<i64> { let d = poly.len(); let mut ret = vec![0; d]; for i in 0 .. d { let mut sum = 0; for j in 0 .. (i + 1) { sum += poly[j] * poly[i - j]; } ret[i] = sum; } return ret; } fn main() { let n: usize = get(); let mut poly: Vec<i64> = vec![0; 2 * n + 1]; for i in 0 .. (n + 1) { poly[i] = 1; } for _ in 0 .. 3 { poly = square(&poly); } println!("{}", poly[2 * n]); }