結果
問題 |
No.1229 ラグビーの得点パターン
|
ユーザー |
![]() |
提出日時 | 2020-09-28 20:06:28 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 3,352 bytes |
コンパイル時間 | 14,228 ms |
コンパイル使用メモリ | 378,100 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 10:42:10 |
合計ジャッジ時間 | 15,315 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 |
ソースコード
fn main() { let n: usize; inputm!(n); let mut ans = 0; for i in 0..=n { for j in 0..=n { for k in 0..=n { if j > i { continue; } if 5 * i + 2 * j + 3 * k == n { ans += 1; } } } } println!("{}", ans); } pub mod input { use std::io; const SPLIT_DELIMITER: char = ' '; /// 空白で区切られた複数の値の読み込む。 /// # Example /// ```ignore /// use cp_template::*; /// /// let (a,b):(usize,usize); /// input!(a,b); /// ``` #[macro_export] #[allow(unused_macros)] macro_rules! inputm { ( $($x:expr ),*) => { { let temp_str = input_line_str(); let mut split_result_iter = temp_str.split_whitespace(); $( let buf_split_result = split_result_iter.next(); let buf_split_result = buf_split_result.unwrap(); ($x) = buf_split_result.parse().unwrap(); )* } }; } /// 文字列を一行読み込む /// # Example /// ```ignore /// use cp_template::*; /// /// let s = input_line_str(); /// ``` pub fn input_line_str() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() } /// 指定した行数を読み込み、二次元配列に変換する。 /// # Examples /// ```ignore /// use cp_template::*; /// /// //10行読み込む。 /// let v = input_vector2d::<usize>(10); /// ``` pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>> where T: std::str::FromStr, { let mut v: Vec<Vec<T>> = Vec::new(); for _ in 0..line { let vec_line = input_vector(); v.push(vec_line); } v } /// 一行読み込み、配列(Vec)に変換する。 /// # Examples /// ```ignore /// use cp_template::*; /// /// let v=input_vector::<usize>(); /// ``` #[allow(clippy::match_wild_err_arm)] pub fn input_vector<T>() -> Vec<T> where T: std::str::FromStr, { let mut v: Vec<T> = Vec::new(); let s = input_line_str(); let split_result = s.split(SPLIT_DELIMITER); for z in split_result { let buf = match z.parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } /// 指定された行数を読み込む #[allow(clippy::match_wild_err_arm)] pub fn input_vector_row<T>(n: usize) -> Vec<T> where T: std::str::FromStr, { let mut v = Vec::with_capacity(n); for _ in 0..n { let buf = match input_line_str().parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } /// StringをVec<char>に変換するトレイト pub trait ToCharVec { fn to_charvec(&self) -> Vec<char>; } impl ToCharVec for String { fn to_charvec(&self) -> Vec<char> { self.to_string().chars().collect::<Vec<_>>() } } } use input::*;