Created
May 21, 2020 11:16
-
-
Save ShinyaKato/95b6fa7ab93f31114429c535e4038593 to your computer and use it in GitHub Desktop.
Rust template just taking input from stdin for competitive programming.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, Read}; | |
macro_rules! input { | |
($it: expr) => ($it.next().unwrap().parse().unwrap()); | |
($it: expr, $T: ty) => ($it.next().unwrap().parse::<$T>().unwrap()); | |
} | |
fn main() { | |
let mut buf = String::new(); | |
io::stdin().read_to_string(&mut buf).unwrap(); | |
let mut it = buf.split_whitespace(); | |
let n: usize = input!(it); | |
let a: Vec<u64> = (0..n).map(|_| input!(it)).collect(); | |
let mut sum: u64 = 0; | |
for i in 0..n { | |
sum += a[i]; | |
} | |
println!("{}", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment