結果

問題 No.1229 ラグビーの得点パターン
ユーザー manta1130manta1130
提出日時 2020-09-28 20:06:28
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,352 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 148,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-15 05:48:22
合計ジャッジ時間 2,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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::*;
0