結果
| 問題 |
No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
|
| ユーザー |
Strorkis
|
| 提出日時 | 2021-03-01 13:51:41 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,963 bytes |
| コンパイル時間 | 12,407 ms |
| コンパイル使用メモリ | 392,768 KB |
| 最終ジャッジ日時 | 2024-11-15 00:19:57 |
| 合計ジャッジ時間 | 13,234 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
error: format argument must be a string literal
--> src/main.rs:11:34
|
11 | Err(e) => panic!(e),
| ^
|
help: you might be missing a string literal to format with
|
11 | Err(e) => panic!("{}", e),
| +++++
error: could not compile `main` (bin "main") due to 1 previous error
ソースコード
mod io {
use std::io::{BufRead, ErrorKind};
use std::str::FromStr;
pub fn scan<R: BufRead, T: FromStr>(r: &mut R) -> T {
let mut tmp = Vec::new();
loop {
let buf = match r.fill_buf() {
Ok(buf) => buf,
Err(e) if e.kind() == ErrorKind::Interrupted => continue,
Err(e) => panic!(e),
};
let (done, used, buf) = {
match buf.iter().position(u8::is_ascii_whitespace) {
Some(i) => (i > 0 || tmp.len() > 0, i + 1, &buf[..i]),
None => (buf.is_empty(), buf.len(), buf),
}
};
if done {
let buf = {
if tmp.is_empty() {
buf
} else {
tmp.extend_from_slice(buf);
&tmp
}
};
let res = std::str::from_utf8(buf).unwrap().parse().ok().unwrap();
r.consume(used);
return res;
}
tmp.extend_from_slice(buf);
r.consume(used);
}
}
}
#[allow(unused_macros)]
fn run<R: std::io::BufRead, W: std::io::Write>(reader: &mut R, writer: &mut W) {
macro_rules! scan {
([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::<Vec<_>>());
(($($t:tt),*)) => (($(scan!($t)),*));
([u8]) => (scan!(String).into_bytes());
($t:ty) => (io::scan::<_, $t>(reader));
}
macro_rules! println {
($($arg:tt)*) => (writeln!(writer, $($arg)*).ok());
}
let n = scan!(usize);
let a = scan!([u64; n]);
println!("{}", a.iter().sum::<u64>());
}
fn main() {
let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
let mut reader = std::io::BufReader::new(stdin.lock());
let mut writer = std::io::BufWriter::new(stdout.lock());
run(&mut reader, &mut writer);
}
Strorkis