/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 2ms 284.0 KiB

Code

// Author: @Drydock
use std::io::{self, Read};

fn main() {
    solve();
}

fn solve() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let mut it = I::new(&input);
    let t: usize = it.n();
    let mut o = String::new();
    for _ in 0..t {
        let x: i32 = it.n();
        let y: i32 = it.n();
        let mut a = -1;
        if x != 1 && y != 1 {
            let mut k = 1;
            while k <= 100 {
                if k % x != 0 && k % y != 0 {
                    a = k;
                    break;
                }
                k += 1;
            }
        }
        o.push_str(&a.to_string());
        o.push('\n');
    }

    print!("{}", o);
}

struct I<'a> {
    w: std::str::SplitWhitespace<'a>,
}

impl<'a> I<'a> {
    fn new(s: &'a str) -> Self {
        Self { w: s.split_whitespace() }
    }

    fn n<T: std::str::FromStr>(&mut self) -> T {
        self.w.next().unwrap().parse().ok().unwrap()
    }
}

Information

Submit By
Type
Submission
Problem
P1235 A. Valid Integer
Contest
Happy New Year 2026
Language
Rust 2021 (Rust 1.75.0)
Submit At
2026-01-06 14:34:09
Judged At
2026-01-06 14:34:09
Judged By
Score
100
Total Time
2ms
Peak Memory
320.0 KiB