結果
| 問題 |
No.289 数字を全て足そう
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-27 09:32:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 734 bytes |
| コンパイル時間 | 14,166 ms |
| コンパイル使用メモリ | 386,956 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 15:26:29 |
| 合計ジャッジ時間 | 15,402 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#[macro_export]
macro_rules! setup {
{ mut $input:ident: SplitWhitespace $(,)? } => {
use std::io::Read;
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).ok();
let mut $input = buf.split_whitespace();
};
}
#[macro_export]
macro_rules! parse_next {
($str_iter:expr) => {
$str_iter.next().unwrap().parse().ok().unwrap()
};
}
fn main() {
setup! { mut input: SplitWhitespace };
let s: String = parse_next!(input);
let ans = (|| {
s.chars()
.fold(0, |acc, c| match u64::from_str_radix(&c.to_string(), 10) {
Ok(n) => acc + n,
Err(_) => acc,
})
})();
println!("{}", ans);
}