結果

問題 No.9009 改行区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー mai
提出日時 2021-04-21 02:13:10
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 34 ms / 3,000 ms
コード長 863 bytes
コンパイル時間 12,738 ms
コンパイル使用メモリ 396,068 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-04 05:50:42
合計ジャッジ時間 13,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `collections::*`
 --> src/main.rs:1:11
  |
1 | use std::{collections::*, io::Read};
  |           ^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

ソースコード

diff #

use std::{collections::*, io::Read};

fn take_token<R: std::io::BufRead>(cin: &mut R) -> String {
    cin.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
}
#[allow(unused)]
macro_rules! scan {
    ($io:expr => $t:ty) => (take_token(&mut $io).parse::<$t>().unwrap());
    ($io:expr => $t:tt * $n:expr) => ((0..$n).map(|_| scan!($io => $t)).collect::<Vec<_>>());
    ($io:expr => $($t:tt),*) => (($(scan!($io => $t)),*));
}
#[allow(unused)]
macro_rules! scan_itr {
    ($io:expr => $t:tt * $n:expr) => ((0..$n).map(|_| scan!($io => $t)));
}

fn main() {
    solve(std::io::stdin().lock())
}

fn solve<R: std::io::BufRead>(mut cin: R) {
    let n = scan!(cin => i32);
    let total = scan_itr!(cin => i64 * n).sum::<i64>();
    println!("{}", total);
}
0