Submission #3450751


Source Code Expand

use scanner::Scanner;
use std::cmp::max;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let mut a = 1u64;
    let mut b = 1u64;
    let mut ans = 1;
    for _ in 0..n {
        let x: u64 = sc.read();
        let y: u64 = sc.read();
        ans = max(if a % x == 0 { a / x } else { a / x + 1 }, if b % y == 0 { b / y } else { b / y + 1 });
        a = ans * x;
        b = ans * y;
    }
    println!("{}", a + b);
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User relieved_face
Language Rust (1.15.1)
Score 300
Code Size 1362 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Compile Error

warning: value assigned to `ans` is never read, #[warn(unused_assignments)] on by default
 --> ./Main.rs:9:9
  |
9 |     let mut ans = 1;
  |         ^^^^^^^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 2 ms 4352 KB
0_001.txt AC 2 ms 4352 KB
0_002.txt AC 2 ms 4352 KB
1_003.txt AC 2 ms 4352 KB
1_004.txt AC 2 ms 4352 KB
1_005.txt AC 2 ms 4352 KB
1_006.txt AC 2 ms 4352 KB
1_007.txt AC 2 ms 4352 KB
1_008.txt AC 2 ms 4352 KB
1_009.txt AC 2 ms 4352 KB
1_010.txt AC 2 ms 4352 KB
1_011.txt AC 2 ms 4352 KB
1_012.txt AC 2 ms 4352 KB
1_013.txt AC 2 ms 4352 KB
1_014.txt AC 2 ms 4352 KB