結果

問題 No.1656 Recuperation
ユーザー yuzu32utyuzu32ut
提出日時 2022-03-08 14:57:49
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,376 bytes
コンパイル時間 3,790 ms
コンパイル使用メモリ 147,420 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:53:08
合計ジャッジ時間 1,827 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(dead_code)]
pub mod ut {
    pub type Result<T = ()> = std::result::Result<T, Box<dyn std::error::Error>>;

    pub mod input {
        use super::Result;
        use std::{error::Error, str::FromStr};

        pub fn string() -> Result<String> {
            let mut buf = String::new();
            std::io::stdin()
                .read_line(&mut buf)
                .map_err(|e| e.into())
                .map(|_| buf.trim().to_string())
        }

        pub fn single<T: FromStr>() -> Result<T>
        where
            <T as FromStr>::Err: Error + 'static,
        {
            string().and_then(|x| x.parse::<T>().map_err(|e| e.into()))
        }

        pub fn vector<T: FromStr>() -> Result<Vec<T>>
        where
            <T as FromStr>::Err: Error + 'static,
        {
            string()?
                .split_ascii_whitespace()
                .map(|x| x.parse::<T>().map_err(|e| e.into()))
                .collect()
        }

        pub fn double<T: FromStr + Copy>() -> Result<(T, T)>
        where
            <T as FromStr>::Err: Error + 'static,
        {
            let v = vector::<T>()?;
            Ok((v[0], v[1]))
        }
    }
}

fn main() -> ut::Result {
    let t = ut::input::single::<usize>()?;
    for _ in 1..=t {
        let (a, b) = ut::input::double::<usize>()?;
        println!("{}", a * b + b);
    }

    Ok(())
}
0