結果
問題 | No.9011 数字を全て足そう(数字だけ) |
ユーザー | yvay5cqe |
提出日時 | 2020-09-20 17:07:58 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 2,923 bytes |
コンパイル時間 | 14,115 ms |
コンパイル使用メモリ | 397,216 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 10:49:07 |
合計ジャッジ時間 | 13,429 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 0 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 1 ms
5,376 KB |
testcase_21 | AC | 0 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
ソースコード
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] use { std::*, std::{cmp::*, collections::*, convert::*, iter::*, marker::*, mem::*, ops::*}, }; fn main() { #![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr()); let mut io = IO::new(r.lock(), w.lock(), e.lock()); let s = io.chars(); let mut ans = 0i64; for &c in s.iter() { ans += (charconv(c, '0') as i64); } println!("{}", ans); } pub fn charconv(c: char, base: char) -> usize { return (c as u8 - base as u8) as usize; } fn dig(n: i64) -> i64 { let mut m = n; let mut ret = 0; while m > 0 { ret += m % 10; m /= 10; } ret } static MX: usize = 1010101; static MOD: i64 = 1000000007; static INF: i64 = std::i64::MAX >> 1; use std::io::*; struct IO<R: Read, W: Write, E: Write> { Read: R, Write: BufWriter<W>, Error: BufWriter<E>, } impl<R: Read, W: Write, E: Write> IO<R, W, E> { fn new(r: R, w: W, e: E) -> IO<R, W, E> { IO { Read: r, Write: BufWriter::new(w), Error: BufWriter::new(e), } } fn read<T>(&mut self) -> T where T: std::str::FromStr, { let next: String = self .Read .by_ref() .bytes() .map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); next.parse().ok().unwrap() } fn chars(&mut self) -> Vec<char> { self.read::<String>().chars().collect() } fn chari(&mut self) -> Vec<i64> { self.chars() .iter() .map(|&c| (c as u8 - b'0') as i64) .collect::<Vec<i64>>() } fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>() } fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> { (0..n).map(|_| self.readn(m)).collect() } fn write<S: ToString>(&mut self, val: S) { self.Write.write(val.to_string().as_bytes()); } fn writeln<S: ToString>(&mut self, val: S) { self.Write.write(val.to_string().as_bytes()); self.Write.write(b"\n"); } fn debug<S: std::fmt::Debug>(&mut self, val: S) { writeln!(self.Error, "(debug) {:?}", &val); } fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) { writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2); } fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>( &mut self, val1: S, val2: T, val3: U, ) { writeln!( self.Error, "(debug3) {:?} -> {:?} -> {:?}", val1, val2, val3 ); } }