Files
contests/atcoder/beginner_contests/abc046/src/bin/c.rs
2022-06-02 14:02:35 +02:00

21 lines
334 B
Rust

use proconio::input;
use std::cmp::max;
fn main(){
input!{
n: u64,
ratios: [(u64, u64); n],
};
let mut a = 1;
let mut t = 1;
for (r_t, r_a) in ratios {
let x = max((r_t + t - 1) / r_t, (r_a + a - 1) / r_a);
t = r_t * x;
a = r_a * x;
}
println!("{}", {a + t});
}