結果
問題 | No.9011 数字を全て足そう(数字だけ) |
ユーザー | yvay5cqe |
提出日時 | 2020-09-20 17:06:35 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,771 bytes |
コンパイル時間 | 12,479 ms |
コンパイル使用メモリ | 379,852 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 10:48:20 |
合計ジャッジ時間 | 13,634 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
ソースコード
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] use { proconio::{marker::*, *}, 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.read::<i64>(); println!("{}", dig(s)); } 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 ); } }