Created
September 21, 2017 09:44
-
-
Save whatalnk/55c015f6b6cde87e7b4f82cde7c3633b to your computer and use it in GitHub Desktop.
AtCoder ABC #070 C
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; | |
fn gets() -> String { | |
let mut buf = String::new(); | |
io::stdin().read_line(&mut buf).ok(); | |
return buf | |
} | |
fn gcd(a: i64, b: i64) -> i64 { | |
if b == 0 { | |
return a; | |
} | |
return gcd(b, a % b); | |
} | |
fn lcm(a: i64, b: i64) -> i64 { | |
let g = gcd(a, b); | |
return a / g * b; | |
} | |
fn main() { | |
let line = gets(); | |
let n = line.trim().parse::<usize>().unwrap(); | |
let mut ans = 1; | |
for _ in 0..n { | |
let line = gets(); | |
let t = line.trim().parse::<i64>().unwrap(); | |
ans = lcm(ans, t); | |
} | |
println!("{}", ans); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment