結果
| 問題 |
No.480 合計
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-21 22:29:20 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 2,645 bytes |
| コンパイル時間 | 13,067 ms |
| コンパイル使用メモリ | 376,516 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 10:19:59 |
| 合計ジャッジ時間 | 13,447 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
use std::io;
use std::str;
pub trait ParseLine {
fn parse_line<R: io::BufRead>(s: &mut Input<R>) -> Self;
}
macro_rules! impl_parse_line {
($($t:ty),*) => {
$(impl ParseLine for $t {
fn parse_line<R: io::BufRead>(s: &mut Input<R>) -> Self {
s.token()
}
})*
};
}
impl_parse_line!(
u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize, f32, f64, String, char
);
macro_rules! impl_parse_line_tuple {
($($t:ident),*) => {
impl<$($t: ParseLine),*> ParseLine for ($($t,)*) {
fn parse_line<R: io::BufRead>(s: &mut Input<R>) -> Self {
($($t::parse_line(s),)*)
}
}
};
}
impl_parse_line_tuple!(T0, T1);
impl_parse_line_tuple!(T0, T1, T2);
impl_parse_line_tuple!(T0, T1, T2, T3);
impl_parse_line_tuple!(T0, T1, T2, T3, T4);
impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5);
impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6);
impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7);
impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8);
impl_parse_line_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9);
pub struct Input<R> {
reader: R,
buffer: Vec<String>,
}
// impl Input<std::io::StdinLock<'static>> {
// pub fn stdio() -> Self {
// let stdin = std::io::stdin();
// let scan = Input::new(stdin.lock());
// scan
// }
// }
impl<R: io::BufRead> Input<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buffer: vec![],
}
}
pub fn token<T: str::FromStr>(&mut self) -> T {
loop {
if let Some(token) = self.buffer.pop() {
return token.parse().ok().expect("Failed parse");
}
let mut input = String::new();
self.reader.read_line(&mut input).expect("Failed read");
self.buffer = input.split_whitespace().rev().map(String::from).collect();
}
}
pub fn read<T: ParseLine>(&mut self) -> T {
ParseLine::parse_line(self)
}
pub fn usize1(&mut self) -> usize {
self.token::<usize>() - 1
}
pub fn isize1(&mut self) -> isize {
self.token::<isize>() - 1
}
pub fn chars(&mut self) -> Vec<char> {
self.token::<String>().chars().collect()
}
pub fn vec<T: ParseLine>(&mut self, n: usize) -> Vec<T> {
(0..n).map(|_| ParseLine::parse_line(self)).collect()
}
}
fn main() {
let mut input = Input::new(std::io::stdin().lock());
let n: usize = input.read();
let mut total = 0;
for i in 1..=n{
total += i;
}
println!("{}", total);
}