QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#862067#9981. Collatz Conjectureucup-team296#AC ✓26ms2304kbRust31.9kb2025-01-18 21:37:412025-01-18 21:38:21

Judging History

你现在查看的是最新测评结果

  • [2025-01-18 21:38:21]
  • 评测
  • 测评结果:AC
  • 用时:26ms
  • 内存:2304kb
  • [2025-01-18 21:37:41]
  • 提交

answer

// https://contest.ucup.ac/contest/1894/problem/9981

use crate::algo_lib::io::input::Input;
use crate::algo_lib::io::output::{BoolOutput, Output};
use crate::algo_lib::misc::test_type::TaskType;
use crate::algo_lib::misc::test_type::TestType;
use crate::algo_lib::numbers::mod_int::ModInt;
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
type PreCalc = ();
fn solve(input: &mut Input, out: &mut Output, _test_case: usize, _data: &mut PreCalc) {
    let a = input.read_long();
    let b = input.read_long();
    let n = input.read_long();
    dynamic_value!(Modulo : u32 = a as u32);
    type Mod = ModInt<Modulo>;
    let b_inv = Mod::new_from_wide(b).inv().unwrap();
    let x = (n - 1) % b + 1;
    let steps = (Mod::new_from_wide(-x) * b_inv).val() as i64;
    out.print_line(n <= x + b * steps);
}
pub static TEST_TYPE: TestType = TestType::MultiNumber;
pub static TASK_TYPE: TaskType = TaskType::Classic;
pub(crate) fn run(mut input: Input, mut output: Output) -> bool {
    let mut pre_calc = ();
    output.set_bool_output(BoolOutput::YesNo);
    match TEST_TYPE {
        TestType::Single => solve(&mut input, &mut output, 1, &mut pre_calc),
        TestType::MultiNumber => {
            let t = input.read();
            for i in 1..=t {
                solve(&mut input, &mut output, i, &mut pre_calc);
            }
        }
        TestType::MultiEof => {
            let mut i = 1;
            while input.peek().is_some() {
                solve(&mut input, &mut output, i, &mut pre_calc);
                i += 1;
            }
        }
    }
    output.flush();
    match TASK_TYPE {
        TaskType::Classic => input.is_empty(),
        TaskType::Interactive => true,
    }
}


fn main() {
    let input = crate::algo_lib::io::input::Input::stdin();
    let output = crate::algo_lib::io::output::Output::stdout();
    run(input, output);
}
pub mod algo_lib {
pub mod collections {
pub mod fx_hash_map {
use crate::algo_lib::misc::lazy_lock::LazyLock;
use std::convert::TryInto;
use std::time::SystemTime;
use std::{
    collections::{HashMap, HashSet},
    hash::{BuildHasherDefault, Hasher},
    ops::BitXor,
};
pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
pub type FxHashSet<V> = HashSet<V, BuildHasherDefault<FxHasher>>;
#[derive(Default)]
pub struct FxHasher {
    hash: usize,
}
static K: LazyLock<usize> = LazyLock::new(|| {
    ((SystemTime::UNIX_EPOCH.elapsed().unwrap().as_nanos().wrapping_mul(2) + 1)
        & 0xFFFFFFFFFFFFFFFF) as usize
});
impl FxHasher {
    #[inline]
    fn add_to_hash(&mut self, i: usize) {
        self.hash = self.hash.rotate_left(5).bitxor(i).wrapping_mul(*K);
    }
}
impl Hasher for FxHasher {
    #[inline]
    fn write(&mut self, mut bytes: &[u8]) {
        let read_usize = |bytes: &[u8]| u64::from_ne_bytes(
            bytes[..8].try_into().unwrap(),
        );
        let mut hash = FxHasher { hash: self.hash };
        while bytes.len() >= 8 {
            hash.add_to_hash(read_usize(bytes) as usize);
            bytes = &bytes[8..];
        }
        if bytes.len() >= 4 {
            hash.add_to_hash(
                u32::from_ne_bytes(bytes[..4].try_into().unwrap()) as usize,
            );
            bytes = &bytes[4..];
        }
        if bytes.len() >= 2 {
            hash.add_to_hash(
                u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as usize,
            );
            bytes = &bytes[2..];
        }
        if !bytes.is_empty() {
            hash.add_to_hash(bytes[0] as usize);
        }
        self.hash = hash.hash;
    }
    #[inline]
    fn write_u8(&mut self, i: u8) {
        self.add_to_hash(i as usize);
    }
    #[inline]
    fn write_u16(&mut self, i: u16) {
        self.add_to_hash(i as usize);
    }
    #[inline]
    fn write_u32(&mut self, i: u32) {
        self.add_to_hash(i as usize);
    }
    #[inline]
    fn write_u64(&mut self, i: u64) {
        self.add_to_hash(i as usize);
    }
    #[inline]
    fn write_usize(&mut self, i: usize) {
        self.add_to_hash(i);
    }
    #[inline]
    fn finish(&self) -> u64 {
        self.hash as u64
    }
}
}
}
pub mod io {
pub mod input {
use std::fs::File;
use std::io::{Read, Stdin};
use std::mem::MaybeUninit;
enum InputSource {
    Stdin(Stdin),
    File(File),
    Slice,
    Delegate(Box<dyn Read + Send>),
}
pub struct Input {
    input: InputSource,
    buf: Vec<u8>,
    at: usize,
    buf_read: usize,
    eol: bool,
}
macro_rules! read_impl {
    ($t:ty, $read_name:ident, $read_vec_name:ident) => {
        pub fn $read_name (& mut self) -> $t { self.read() } pub fn $read_vec_name (& mut
        self, len : usize) -> Vec <$t > { self.read_vec(len) }
    };
    ($t:ty, $read_name:ident, $read_vec_name:ident, $read_pair_vec_name:ident) => {
        read_impl!($t, $read_name, $read_vec_name); pub fn $read_pair_vec_name (& mut
        self, len : usize) -> Vec < ($t, $t) > { self.read_vec(len) }
    };
}
impl Input {
    const DEFAULT_BUF_SIZE: usize = 4096;
    pub fn slice(input: &[u8]) -> Self {
        Self {
            input: InputSource::Slice,
            buf: input.to_vec(),
            at: 0,
            buf_read: input.len(),
            eol: true,
        }
    }
    pub fn stdin() -> Self {
        Self {
            input: InputSource::Stdin(std::io::stdin()),
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
            eol: true,
        }
    }
    pub fn file(file: File) -> Self {
        Self {
            input: InputSource::File(file),
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
            eol: true,
        }
    }
    pub fn delegate(reader: impl Read + Send + 'static) -> Self {
        Self {
            input: InputSource::Delegate(Box::new(reader)),
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            buf_read: 0,
            eol: true,
        }
    }
    pub fn get(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            self.at += 1;
            if res == b'\r' {
                self.eol = true;
                if self.refill_buffer() && self.buf[self.at] == b'\n' {
                    self.at += 1;
                }
                return Some(b'\n');
            }
            self.eol = res == b'\n';
            Some(res)
        } else {
            None
        }
    }
    pub fn peek(&mut self) -> Option<u8> {
        if self.refill_buffer() {
            let res = self.buf[self.at];
            Some(if res == b'\r' { b'\n' } else { res })
        } else {
            None
        }
    }
    pub fn skip_whitespace(&mut self) {
        while let Some(b) = self.peek() {
            if !b.is_ascii_whitespace() {
                return;
            }
            self.get();
        }
    }
    pub fn next_token(&mut self) -> Option<Vec<u8>> {
        self.skip_whitespace();
        let mut res = Vec::new();
        while let Some(c) = self.get() {
            if c.is_ascii_whitespace() {
                break;
            }
            res.push(c);
        }
        if res.is_empty() { None } else { Some(res) }
    }
    pub fn is_exhausted(&mut self) -> bool {
        self.peek().is_none()
    }
    pub fn is_empty(&mut self) -> bool {
        self.skip_whitespace();
        self.is_exhausted()
    }
    pub fn read<T: Readable>(&mut self) -> T {
        T::read(self)
    }
    pub fn read_vec<T: Readable>(&mut self, size: usize) -> Vec<T> {
        let mut res = Vec::with_capacity(size);
        for _ in 0..size {
            res.push(self.read());
        }
        res
    }
    pub fn read_char(&mut self) -> u8 {
        self.skip_whitespace();
        self.get().unwrap()
    }
    read_impl!(u32, read_unsigned, read_unsigned_vec);
    read_impl!(u64, read_u64, read_u64_vec);
    read_impl!(usize, read_size, read_size_vec, read_size_pair_vec);
    read_impl!(i32, read_int, read_int_vec, read_int_pair_vec);
    read_impl!(i64, read_long, read_long_vec, read_long_pair_vec);
    read_impl!(i128, read_i128, read_i128_vec);
    fn refill_buffer(&mut self) -> bool {
        if self.at == self.buf_read {
            self.at = 0;
            self.buf_read = match &mut self.input {
                InputSource::Stdin(stdin) => stdin.read(&mut self.buf).unwrap(),
                InputSource::File(file) => file.read(&mut self.buf).unwrap(),
                InputSource::Delegate(reader) => reader.read(&mut self.buf).unwrap(),
                InputSource::Slice => 0,
            };
            self.buf_read != 0
        } else {
            true
        }
    }
    pub fn is_eol(&self) -> bool {
        self.eol
    }
}
pub trait Readable {
    fn read(input: &mut Input) -> Self;
}
impl Readable for u8 {
    fn read(input: &mut Input) -> Self {
        input.read_char()
    }
}
impl<T: Readable> Readable for Vec<T> {
    fn read(input: &mut Input) -> Self {
        let size = input.read();
        input.read_vec(size)
    }
}
impl<T: Readable, const SIZE: usize> Readable for [T; SIZE] {
    fn read(input: &mut Input) -> Self {
        unsafe {
            let mut res = MaybeUninit::<[T; SIZE]>::uninit();
            for i in 0..SIZE {
                let ptr: *mut T = (*res.as_mut_ptr()).as_mut_ptr();
                ptr.add(i).write(input.read::<T>());
            }
            res.assume_init()
        }
    }
}
macro_rules! read_integer {
    ($($t:ident)+) => {
        $(impl Readable for $t { fn read(input : & mut Input) -> Self { input
        .skip_whitespace(); let mut c = input.get().unwrap(); let sgn = match c { b'-' =>
        { c = input.get().unwrap(); true } b'+' => { c = input.get().unwrap(); false } _
        => false, }; let mut res = 0; loop { assert!(c.is_ascii_digit()); res *= 10; let
        d = (c - b'0') as $t; if sgn { res -= d; } else { res += d; } match input.get() {
        None => break, Some(ch) => { if ch.is_ascii_whitespace() { break; } else { c =
        ch; } } } } res } })+
    };
}
read_integer!(i8 i16 i32 i64 i128 isize u16 u32 u64 u128 usize);
macro_rules! tuple_readable {
    ($($name:ident)+) => {
        impl <$($name : Readable),+> Readable for ($($name,)+) { fn read(input : & mut
        Input) -> Self { ($($name ::read(input),)+) } }
    };
}
tuple_readable! {
    T
}
tuple_readable! {
    T U
}
tuple_readable! {
    T U V
}
tuple_readable! {
    T U V X
}
tuple_readable! {
    T U V X Y
}
tuple_readable! {
    T U V X Y Z
}
tuple_readable! {
    T U V X Y Z A
}
tuple_readable! {
    T U V X Y Z A B
}
tuple_readable! {
    T U V X Y Z A B C
}
tuple_readable! {
    T U V X Y Z A B C D
}
tuple_readable! {
    T U V X Y Z A B C D E
}
tuple_readable! {
    T U V X Y Z A B C D E F
}
}
pub mod output {
use std::cmp::Reverse;
use std::fs::File;
use std::io::{Stdout, Write};
#[derive(Copy, Clone)]
pub enum BoolOutput {
    YesNo,
    YesNoCaps,
    PossibleImpossible,
    Custom(&'static str, &'static str),
}
impl BoolOutput {
    pub fn output(&self, output: &mut Output, val: bool) {
        (if val { self.yes() } else { self.no() }).write(output);
    }
    fn yes(&self) -> &str {
        match self {
            BoolOutput::YesNo => "Yes",
            BoolOutput::YesNoCaps => "YES",
            BoolOutput::PossibleImpossible => "Possible",
            BoolOutput::Custom(yes, _) => yes,
        }
    }
    fn no(&self) -> &str {
        match self {
            BoolOutput::YesNo => "No",
            BoolOutput::YesNoCaps => "NO",
            BoolOutput::PossibleImpossible => "Impossible",
            BoolOutput::Custom(_, no) => no,
        }
    }
}
enum OutputDest<'s> {
    Stdout(Stdout),
    File(File),
    Buf(&'s mut Vec<u8>),
    Delegate(Box<dyn Write + 's>),
}
pub struct Output<'s> {
    output: OutputDest<'s>,
    buf: Vec<u8>,
    at: usize,
    bool_output: BoolOutput,
    precision: Option<usize>,
    separator: u8,
}
impl<'s> Output<'s> {
    pub fn buf(buf: &'s mut Vec<u8>) -> Self {
        Self::new(OutputDest::Buf(buf))
    }
    pub fn delegate(delegate: impl Write + 'static) -> Self {
        Self::new(OutputDest::Delegate(Box::new(delegate)))
    }
    fn new(output: OutputDest<'s>) -> Self {
        Self {
            output,
            buf: vec![0; Self::DEFAULT_BUF_SIZE],
            at: 0,
            bool_output: BoolOutput::YesNoCaps,
            precision: None,
            separator: b' ',
        }
    }
}
impl Output<'static> {
    pub fn stdout() -> Self {
        Self::new(OutputDest::Stdout(std::io::stdout()))
    }
    pub fn file(file: File) -> Self {
        Self::new(OutputDest::File(file))
    }
}
impl Output<'_> {
    const DEFAULT_BUF_SIZE: usize = 4096;
    pub fn flush(&mut self) {
        if self.at != 0 {
            match &mut self.output {
                OutputDest::Stdout(stdout) => {
                    stdout.write_all(&self.buf[..self.at]).unwrap();
                    stdout.flush().unwrap();
                }
                OutputDest::File(file) => {
                    file.write_all(&self.buf[..self.at]).unwrap();
                    file.flush().unwrap();
                }
                OutputDest::Buf(buf) => buf.extend_from_slice(&self.buf[..self.at]),
                OutputDest::Delegate(delegate) => {
                    delegate.write_all(&self.buf[..self.at]).unwrap();
                    delegate.flush().unwrap();
                }
            }
            self.at = 0;
        }
    }
    pub fn print<T: Writable>(&mut self, s: T) {
        s.write(self);
    }
    pub fn print_line<T: Writable>(&mut self, s: T) {
        self.print(s);
        self.put(b'\n');
    }
    pub fn put(&mut self, b: u8) {
        self.buf[self.at] = b;
        self.at += 1;
        if self.at == self.buf.len() {
            self.flush();
        }
    }
    pub fn print_per_line<T: Writable>(&mut self, arg: &[T]) {
        self.print_per_line_iter(arg.iter());
    }
    pub fn print_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        let mut first = true;
        for e in iter {
            if first {
                first = false;
            } else {
                self.put(self.separator);
            }
            e.write(self);
        }
    }
    pub fn print_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        self.print_iter(iter);
        self.put(b'\n');
    }
    pub fn print_per_line_iter<T: Writable, I: Iterator<Item = T>>(&mut self, iter: I) {
        for e in iter {
            e.write(self);
            self.put(b'\n');
        }
    }
    pub fn set_bool_output(&mut self, bool_output: BoolOutput) {
        self.bool_output = bool_output;
    }
    pub fn set_precision(&mut self, precision: usize) {
        self.precision = Some(precision);
    }
    pub fn reset_precision(&mut self) {
        self.precision = None;
    }
    pub fn get_precision(&self) -> Option<usize> {
        self.precision
    }
    pub fn separator(&self) -> u8 {
        self.separator
    }
    pub fn set_separator(&mut self, separator: u8) {
        self.separator = separator;
    }
}
impl Write for Output<'_> {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let mut start = 0usize;
        let mut rem = buf.len();
        while rem > 0 {
            let len = (self.buf.len() - self.at).min(rem);
            self.buf[self.at..self.at + len].copy_from_slice(&buf[start..start + len]);
            self.at += len;
            if self.at == self.buf.len() {
                self.flush();
            }
            start += len;
            rem -= len;
        }
        Ok(buf.len())
    }
    fn flush(&mut self) -> std::io::Result<()> {
        self.flush();
        Ok(())
    }
}
pub trait Writable {
    fn write(&self, output: &mut Output);
}
impl Writable for &str {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}
impl Writable for String {
    fn write(&self, output: &mut Output) {
        output.write_all(self.as_bytes()).unwrap();
    }
}
impl Writable for char {
    fn write(&self, output: &mut Output) {
        output.put(*self as u8);
    }
}
impl Writable for u8 {
    fn write(&self, output: &mut Output) {
        output.put(*self);
    }
}
impl<T: Writable> Writable for [T] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}
impl<T: Writable, const N: usize> Writable for [T; N] {
    fn write(&self, output: &mut Output) {
        output.print_iter(self.iter());
    }
}
impl<T: Writable + ?Sized> Writable for &T {
    fn write(&self, output: &mut Output) {
        T::write(self, output)
    }
}
impl<T: Writable> Writable for Vec<T> {
    fn write(&self, output: &mut Output) {
        self.as_slice().write(output);
    }
}
impl Writable for () {
    fn write(&self, _output: &mut Output) {}
}
macro_rules! write_to_string {
    ($($t:ident)+) => {
        $(impl Writable for $t { fn write(& self, output : & mut Output) { self
        .to_string().write(output); } })+
    };
}
write_to_string!(u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize);
macro_rules! tuple_writable {
    ($name0:ident $($name:ident : $id:tt)*) => {
        impl <$name0 : Writable, $($name : Writable,)*> Writable for ($name0, $($name,)*)
        { fn write(& self, out : & mut Output) { self.0.write(out); $(out.put(out
        .separator); self.$id .write(out);)* } }
    };
}
tuple_writable! {
    T
}
tuple_writable! {
    T U : 1
}
tuple_writable! {
    T U : 1 V : 2
}
tuple_writable! {
    T U : 1 V : 2 X : 3
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6 B : 7
}
tuple_writable! {
    T U : 1 V : 2 X : 3 Y : 4 Z : 5 A : 6 B : 7 C : 8
}
impl<T: Writable> Writable for Option<T> {
    fn write(&self, output: &mut Output) {
        match self {
            None => (-1).write(output),
            Some(t) => t.write(output),
        }
    }
}
impl Writable for bool {
    fn write(&self, output: &mut Output) {
        let bool_output = output.bool_output;
        bool_output.output(output, *self)
    }
}
impl<T: Writable> Writable for Reverse<T> {
    fn write(&self, output: &mut Output) {
        self.0.write(output);
    }
}
}
}
pub mod misc {
pub mod lazy_lock {
use std::cell::UnsafeCell;
use std::mem::ManuallyDrop;
use std::ops::Deref;
use std::sync::Once;
union Data<T, F> {
    value: ManuallyDrop<T>,
    f: ManuallyDrop<F>,
}
pub struct LazyLock<T, F = fn() -> T> {
    once: Once,
    data: UnsafeCell<Data<T, F>>,
}
impl<T, F: FnOnce() -> T> LazyLock<T, F> {
    #[inline]
    pub const fn new(f: F) -> LazyLock<T, F> {
        LazyLock {
            once: Once::new(),
            data: UnsafeCell::new(Data { f: ManuallyDrop::new(f) }),
        }
    }
    #[inline]
    pub fn force(this: &LazyLock<T, F>) -> &T {
        this.once
            .call_once(|| {
                let data = unsafe { &mut *this.data.get() };
                let f = unsafe { ManuallyDrop::take(&mut data.f) };
                let value = f();
                data.value = ManuallyDrop::new(value);
            });
        unsafe { &(*this.data.get()).value }
    }
}
impl<T, F: FnOnce() -> T> Deref for LazyLock<T, F> {
    type Target = T;
    #[inline]
    fn deref(&self) -> &T {
        LazyLock::force(self)
    }
}
unsafe impl<T: Sync + Send, F: Send> Sync for LazyLock<T, F> {}
}
pub mod test_type {
pub enum TestType {
    Single,
    MultiNumber,
    MultiEof,
}
pub enum TaskType {
    Classic,
    Interactive,
}
}
pub mod value {
use std::hash::Hash;
pub trait Value<T>: Copy + Ord + Hash + Default {
    fn val() -> T;
}
pub trait ConstValue<T>: Value<T> {
    const VAL: T;
}
impl<T, V: ConstValue<T>> Value<T> for V {
    fn val() -> T {
        Self::VAL
    }
}
#[macro_export]
macro_rules! value {
    ($v:vis $name:ident : $t:ty = $val:expr) => {
        #[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Default)] $v struct
        $name {} impl $crate ::algo_lib::misc::value::ConstValue <$t > for $name { const
        VAL : $t = $val; }
    };
}
pub trait DynamicValue<T>: Value<T> {
    fn set(t: T);
}
#[macro_export]
macro_rules! dynamic_value {
    ($v:vis $name:ident : $t:ty) => {
        thread_local! { #[allow(non_upper_case_globals)] static $name : std::cell::Cell <
        Option <$t >> = std::cell::Cell::new(None); } #[derive(Copy, Clone, Eq,
        PartialEq, Ord, PartialOrd, Hash, Default)] $v struct $name {} impl $crate
        ::algo_lib::misc::value::DynamicValue <$t > for $name { fn set(t : $t) { $name
        .with(| c | c.set(Some(t))); } } impl $crate ::algo_lib::misc::value::Value <$t >
        for $name { fn val() -> $t { $name .with(| c | c.get().unwrap()) } }
    };
    ($v:vis $name:ident : $t:ty = $val:expr) => {
        dynamic_value!($v $name : $t); <$name as $crate
        ::algo_lib::misc::value::DynamicValue <$t >>::set($val);
    };
}
}
pub mod when {
#[macro_export]
macro_rules! when {
    {$($cond:expr => $then:expr,)*} => {
        match () { $(_ if $cond => $then,)* _ => unreachable!(), }
    };
    {$($cond:expr => $then:expr,)* else $(=>)? $else:expr $(,)?} => {
        match () { $(_ if $cond => $then,)* _ => $else, }
    };
}
}
}
pub mod numbers {
pub mod gcd {
use crate::algo_lib::numbers::num_traits::algebra::{
    IntegerMultiplicationMonoid, IntegerSemiRingWithSub, Zero,
};
use std::mem::swap;
pub fn extended_gcd<T: IntegerSemiRingWithSub + Copy>(a: T, b: T) -> (T, T, T) {
    if a == T::zero() {
        (b, T::zero(), T::one())
    } else {
        let (d, y, mut x) = extended_gcd(b % a, a);
        x -= b / a * y;
        (d, x, y)
    }
}
pub fn gcd<T: Copy + Zero + IntegerMultiplicationMonoid>(mut a: T, mut b: T) -> T {
    while b != T::zero() {
        a %= b;
        swap(&mut a, &mut b);
    }
    a
}
pub fn lcm<T: Copy + Zero + IntegerMultiplicationMonoid>(a: T, b: T) -> T {
    (a / gcd(a, b)) * b
}
pub fn remainder<T: IntegerSemiRingWithSub + Copy>(
    a1: T,
    n1: T,
    a2: T,
    n2: T,
) -> Option<T> {
    let (d, m1, m2) = extended_gcd(n1, n2);
    if (a2 - a1) % d != T::zero() {
        return None;
    }
    let m = lcm(n1, n2);
    Some(((a1 * m2) % n1 * n2 + (a2 * m1) % n2 * n1) % m)
}
}
pub mod mod_int {
use crate::algo_lib::collections::fx_hash_map::FxHashMap;
use crate::algo_lib::io::input::{Input, Readable};
use crate::algo_lib::io::output::{Output, Writable};
use crate::algo_lib::misc::value::Value;
use crate::algo_lib::numbers::gcd::extended_gcd;
use crate::algo_lib::numbers::num_traits::algebra::{Field, One, Zero};
use crate::algo_lib::numbers::num_traits::as_index::AsIndex;
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
use crate::{value, when};
use std::fmt::{Display, Formatter};
use std::hash::Hash;
use std::marker::PhantomData;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};



pub trait BaseModInt<T>: Field + Copy {
    fn from(v: T) -> Self;
    fn module() -> T;
    fn value(&self) -> T;
}
macro_rules! mod_int {
    ($name:ident, $t:ty, $s:ty, $w:ty) => {
        #[derive(Copy, Clone, Eq, PartialEq, Hash, Default)] pub struct $name < V : Value
        <$t >> { n : $t, phantom : PhantomData < V >, } impl < V : Value <$t >> $name < V
        > { unsafe fn unchecked_new(n : $t) -> Self { debug_assert!(n < V::val()); Self {
        n, phantom : Default::default(), } } unsafe fn maybe_subtract_mod(mut n : $t) ->
        $t { debug_assert!(n < 2 * V::val()); if n >= V::val() { n -= V::val(); } n } }
        impl < V : Value <$t >> $name < V > { pub fn new(n : $t) -> Self { unsafe {
        Self::unchecked_new(n % (V::val())) } } pub fn new_signed(n : $s) -> Self {
        unsafe { Self::unchecked_new(Self::maybe_subtract_mod((n % (V::val() as $s) +
        V::val() as $s) as $t,)) } } pub fn val(& self) -> $t { self.n } } impl < V :
        Value <$t >> $name < V > { pub fn log(& self, alpha : Self) -> $t { let mut base
        = FxHashMap::default(); let mut exp = 0; let mut pow = Self::one(); let mut inv =
        * self; let alpha_inv = alpha.inv().unwrap(); while exp * exp < Self::module() {
        if inv == Self::one() { return exp; } base.insert(inv, exp); exp += 1; pow *=
        alpha; inv *= alpha_inv; } let step = pow; let mut i = 1; loop { if let Some(b) =
        base.get(& pow) { break exp * i + * b; } pow *= step; i += 1; } } } impl < V :
        Value <$t >> $name < V > { pub fn new_from_wide(n : $w) -> Self { unsafe {
        Self::unchecked_new(Self::maybe_subtract_mod((n % V::val() as $w + V::val() as
        $w) as $t,)) } } } impl < V : Value <$t >> Invertible for $name < V > { type
        Output = Self; fn inv(& self) -> Option < Self > { let (g, x, _) =
        extended_gcd(self.n as $w, V::val() as $w); if g != 1 { None } else {
        Some(Self::new_from_wide(x)) } } } impl < V : Value <$t >> BaseModInt <$t > for
        $name < V > { fn from(v : $t) -> Self { Self::new(v) } fn module() -> $t {
        V::val() } fn value(& self) -> $t { self.n } } impl < V : Value <$t >> From <$t >
        for $name < V > { fn from(n : $t) -> Self { Self::new(n) } } impl < V : Value <$t
        >> AddAssign for $name < V > { fn add_assign(& mut self, rhs : Self) { self.n =
        unsafe { Self::maybe_subtract_mod(self.n + rhs.n) }; } } impl < V : Value <$t >>
        Add for $name < V > { type Output = Self; fn add(mut self, rhs : Self) ->
        Self::Output { self += rhs; self } } impl < V : Value <$t >> SubAssign for $name
        < V > { fn sub_assign(& mut self, rhs : Self) { self.n = unsafe {
        Self::maybe_subtract_mod(self.n + V::val() - rhs.n) }; } } impl < V : Value <$t
        >> Sub for $name < V > { type Output = Self; fn sub(mut self, rhs : Self) ->
        Self::Output { self -= rhs; self } } impl < V : Value <$t >> MulAssign for $name
        < V > { fn mul_assign(& mut self, rhs : Self) { self.n = ((self.n as $w) * (rhs.n
        as $w) % (V::val() as $w)) as $t; } } impl < V : Value <$t >> Mul for $name < V >
        { type Output = Self; fn mul(mut self, rhs : Self) -> Self::Output { self *= rhs;
        self } } impl < V : Value <$t >> DivAssign for $name < V > {
        #[allow(clippy::suspicious_op_assign_impl)] fn div_assign(& mut self, rhs : Self)
        { * self *= rhs.inv().unwrap(); } } impl < V : Value <$t >> Div for $name < V > {
        type Output = Self; fn div(mut self, rhs : Self) -> Self::Output { self /= rhs;
        self } } impl < V : Value <$t >> Neg for $name < V > { type Output = Self; fn
        neg(mut self) -> Self::Output { if self.n != 0 { self.n = V::val() - self.n; }
        self } } impl < V : Value <$t >> Display for $name < V > { fn fmt(& self, f : &
        mut Formatter <'_ >) -> std::fmt::Result { <$t as Display >::fmt(& self.n, f) } }
        impl < V : Value <$t >> Readable for $name < V > { fn read(input : & mut Input)
        -> Self { Self::new(input.read()) } } impl < V : Value <$t >> Writable for $name
        < V > { fn write(& self, output : & mut Output) { self.n.write(output); } } impl
        < V : Value <$t >> Zero for $name < V > { fn zero() -> Self { unsafe {
        Self::unchecked_new(0) } } } impl < V : Value <$t >> One for $name < V > { fn
        one() -> Self { Self::new(1) } } impl < V : Value <$t >> std::fmt::Debug for
        $name < V > { fn fmt(& self, f : & mut Formatter) -> std::fmt::Result { let max =
        100; when! { self.n <= max => write!(f, "{}", self.n), self.n >= V::val() - max
        => write!(f, "-{}", V::val() - self.n), else => { for denominator in 1..max { for
        num in 1..max { if Self::new(num) / Self::new(denominator) == * self { return
        write!(f, "{}/{}", num, denominator); } if - Self::new(num) /
        Self::new(denominator) == * self { return write!(f, "-{}/{}", num, denominator);
        } } } write!(f, "(?? {} ??)", self.n) }, } } } impl < V : Value <$t >> AsIndex
        for $name < V > { fn from_index(idx : usize) -> Self { let v = idx as $w; if v >=
        V::val() as $w { Self::new_from_wide(v) } else { unsafe { Self::unchecked_new(v
        as $t) } } } fn to_index(self) -> usize { self.n.to_index() } }
    };
}
mod_int!(ModInt, u32, i32, i64);
mod_int!(ModInt64, u64, i64, i128);
value!(pub Val7 : u32 = 1_000_000_007);
pub type ModInt7 = ModInt<Val7>;
value!(pub Val9 : u32 = 1_000_000_009);
pub type ModInt9 = ModInt<Val9>;
value!(pub ValF : u32 = 998_244_353);
pub type ModIntF = ModInt<ValF>;
}
pub mod num_traits {
pub mod algebra {
use crate::algo_lib::numbers::num_traits::invertible::Invertible;
use std::ops::{
    Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign,
};
pub trait Zero {
    fn zero() -> Self;
}
pub trait One {
    fn one() -> Self;
}
pub trait AdditionMonoid: Add<Output = Self> + AddAssign + Zero + Eq + Sized {}
impl<T: Add<Output = Self> + AddAssign + Zero + Eq> AdditionMonoid for T {}
pub trait AdditionMonoidWithSub: AdditionMonoid + Sub<Output = Self> + SubAssign {}
impl<T: AdditionMonoid + Sub<Output = Self> + SubAssign> AdditionMonoidWithSub for T {}
pub trait AdditionGroup: AdditionMonoidWithSub + Neg<Output = Self> {}
impl<T: AdditionMonoidWithSub + Neg<Output = Self>> AdditionGroup for T {}
pub trait MultiplicationMonoid: Mul<Output = Self> + MulAssign + One + Eq + Sized {}
impl<T: Mul<Output = Self> + MulAssign + One + Eq> MultiplicationMonoid for T {}
pub trait IntegerMultiplicationMonoid: MultiplicationMonoid + Div<
        Output = Self,
    > + Rem<Output = Self> + DivAssign + RemAssign {}
impl<
    T: MultiplicationMonoid + Div<Output = Self> + Rem<Output = Self> + DivAssign
        + RemAssign,
> IntegerMultiplicationMonoid for T {}
pub trait MultiplicationGroup: MultiplicationMonoid + Div<
        Output = Self,
    > + DivAssign + Invertible<Output = Self> {}
impl<
    T: MultiplicationMonoid + Div<Output = Self> + DivAssign + Invertible<Output = Self>,
> MultiplicationGroup for T {}
pub trait SemiRing: AdditionMonoid + MultiplicationMonoid {}
impl<T: AdditionMonoid + MultiplicationMonoid> SemiRing for T {}
pub trait SemiRingWithSub: AdditionMonoidWithSub + SemiRing {}
impl<T: AdditionMonoidWithSub + SemiRing> SemiRingWithSub for T {}
pub trait Ring: SemiRing + AdditionGroup {}
impl<T: SemiRing + AdditionGroup> Ring for T {}
pub trait IntegerSemiRing: SemiRing + IntegerMultiplicationMonoid {}
impl<T: SemiRing + IntegerMultiplicationMonoid> IntegerSemiRing for T {}
pub trait IntegerSemiRingWithSub: SemiRingWithSub + IntegerSemiRing {}
impl<T: SemiRingWithSub + IntegerSemiRing> IntegerSemiRingWithSub for T {}
pub trait IntegerRing: IntegerSemiRing + Ring {}
impl<T: IntegerSemiRing + Ring> IntegerRing for T {}
pub trait Field: Ring + MultiplicationGroup {}
impl<T: Ring + MultiplicationGroup> Field for T {}
macro_rules! zero_one_integer_impl {
    ($($t:ident)+) => {
        $(impl Zero for $t { fn zero() -> Self { 0 } } impl One for $t { fn one() -> Self
        { 1 } })+
    };
}
zero_one_integer_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);
}
pub mod as_index {
pub trait AsIndex {
    fn from_index(idx: usize) -> Self;
    fn to_index(self) -> usize;
}
macro_rules! from_index_impl {
    ($($t:ident)+) => {
        $(impl AsIndex for $t { fn from_index(idx : usize) -> Self { idx as $t } fn
        to_index(self) -> usize { self as usize } })+
    };
}
from_index_impl!(i128 i64 i32 i16 i8 isize u128 u64 u32 u16 u8 usize);
}
pub mod invertible {
pub trait Invertible {
    type Output;
    fn inv(&self) -> Option<Self::Output>;
}
}
}
}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 2304kb

input:

7
2 1 1
2 1 2
2 1 3
2 1 100
314 159 265
314 159 2653
314 159 26535

output:

Yes
Yes
No
No
Yes
Yes
No

result:

ok 7 tokens

Test #2:

score: 0
Accepted
time: 10ms
memory: 2176kb

input:

100000
123 457 1
123 457 2
123 457 3
123 457 4
123 457 5
123 457 6
123 457 7
123 457 8
123 457 9
123 457 10
123 457 11
123 457 12
123 457 13
123 457 14
123 457 15
123 457 16
123 457 17
123 457 18
123 457 19
123 457 20
123 457 21
123 457 22
123 457 23
123 457 24
123 457 25
123 457 26
123 457 27
123 4...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #3:

score: 0
Accepted
time: 10ms
memory: 2176kb

input:

100000
457 123 1
457 123 2
457 123 3
457 123 4
457 123 5
457 123 6
457 123 7
457 123 8
457 123 9
457 123 10
457 123 11
457 123 12
457 123 13
457 123 14
457 123 15
457 123 16
457 123 17
457 123 18
457 123 19
457 123 20
457 123 21
457 123 22
457 123 23
457 123 24
457 123 25
457 123 26
457 123 27
457 1...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #4:

score: 0
Accepted
time: 6ms
memory: 2176kb

input:

100000
3 100000 1
3 100000 2
3 100000 3
3 100000 4
3 100000 5
3 100000 6
3 100000 7
3 100000 8
3 100000 9
3 100000 10
3 100000 11
3 100000 12
3 100000 13
3 100000 14
3 100000 15
3 100000 16
3 100000 17
3 100000 18
3 100000 19
3 100000 20
3 100000 21
3 100000 22
3 100000 23
3 100000 24
3 100000 25
3 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #5:

score: 0
Accepted
time: 7ms
memory: 2176kb

input:

100000
100000 3 1
100000 3 2
100000 3 3
100000 3 4
100000 3 5
100000 3 6
100000 3 7
100000 3 8
100000 3 9
100000 3 10
100000 3 11
100000 3 12
100000 3 13
100000 3 14
100000 3 15
100000 3 16
100000 3 17
100000 3 18
100000 3 19
100000 3 20
100000 3 21
100000 3 22
100000 3 23
100000 3 24
100000 3 25
10...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #6:

score: 0
Accepted
time: 10ms
memory: 2176kb

input:

100000
1234 567 1
1234 567 2
1234 567 3
1234 567 4
1234 567 5
1234 567 6
1234 567 7
1234 567 8
1234 567 9
1234 567 10
1234 567 11
1234 567 12
1234 567 13
1234 567 14
1234 567 15
1234 567 16
1234 567 17
1234 567 18
1234 567 19
1234 567 20
1234 567 21
1234 567 22
1234 567 23
1234 567 24
1234 567 25
12...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #7:

score: 0
Accepted
time: 9ms
memory: 2048kb

input:

100000
567 1234 1
567 1234 2
567 1234 3
567 1234 4
567 1234 5
567 1234 6
567 1234 7
567 1234 8
567 1234 9
567 1234 10
567 1234 11
567 1234 12
567 1234 13
567 1234 14
567 1234 15
567 1234 16
567 1234 17
567 1234 18
567 1234 19
567 1234 20
567 1234 21
567 1234 22
567 1234 23
567 1234 24
567 1234 25
56...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #8:

score: 0
Accepted
time: 7ms
memory: 2176kb

input:

100000
11 20000 1
11 20000 2
11 20000 3
11 20000 4
11 20000 5
11 20000 6
11 20000 7
11 20000 8
11 20000 9
11 20000 10
11 20000 11
11 20000 12
11 20000 13
11 20000 14
11 20000 15
11 20000 16
11 20000 17
11 20000 18
11 20000 19
11 20000 20
11 20000 21
11 20000 22
11 20000 23
11 20000 24
11 20000 25
11...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #9:

score: 0
Accepted
time: 8ms
memory: 2176kb

input:

100000
20000 11 1
20000 11 2
20000 11 3
20000 11 4
20000 11 5
20000 11 6
20000 11 7
20000 11 8
20000 11 9
20000 11 10
20000 11 11
20000 11 12
20000 11 13
20000 11 14
20000 11 15
20000 11 16
20000 11 17
20000 11 18
20000 11 19
20000 11 20
20000 11 21
20000 11 22
20000 11 23
20000 11 24
20000 11 25
20...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #10:

score: 0
Accepted
time: 6ms
memory: 2304kb

input:

100000
10 9 46
7 10 75
8 5 28
2 9 25
8 3 14
6 1 11
6 7 43
10 1 100
6 7 7
10 9 74
8 9 25
4 7 23
6 5 32
10 7 67
2 5 9
7 2 9
8 3 24
3 10 72
7 8 80
2 9 63
9 4 89
9 7 65
3 2 23
7 4 83
8 7 54
5 2 83
8 7 67
9 8 7
8 3 5
7 2 21
9 10 64
5 1 58
8 9 64
7 6 92
3 7 85
3 4 81
3 7 52
8 3 93
8 3 49
10 3 63
8 5 62
3 ...

output:

No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
Yes
No
No
Yes
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
Yes
No
N...

result:

ok 100000 tokens

Test #11:

score: 0
Accepted
time: 11ms
memory: 2048kb

input:

100000
734 721 305043
803 570 314107
151 173 961985
99 158 637673
223 992 251278
128 675 45643
37 515 402356
920 643 166597
607 246 261024
922 153 82929
963 845 862581
525 898 55977
471 734 239060
401 155 140267
416 587 162998
646 835 165455
115 263 455493
526 965 19267
747 968 848208
485 58 581362
...

output:

No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No...

result:

ok 100000 tokens

Test #12:

score: 0
Accepted
time: 17ms
memory: 2176kb

input:

100000
32231 92266 782178617
42230 96003 6217695170
80182 12377 8701700997
31033 52983 6302513359
62119 12786 1119273204
47041 95623 9096117073
31597 62488 6503179735
68149 95382 7983811944
43779 23956 7205672312
42079 13667 8875242043
74808 71447 2510801750
30403 25937 7075700089
23049 52477 533016...

output:

No
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
Yes
No
No
No
No...

result:

ok 100000 tokens

Test #13:

score: 0
Accepted
time: 17ms
memory: 2048kb

input:

100000
3810923 5708808 87470435846326
5965262 5386583 90515929776547
3844735 7834949 51374503391657
4252291 1624223 55591304698259
2457933 4620706 97200660986648
7466255 9990183 60765953374093
7441773 6851918 59567739236703
4360951 5147843 30543734215896
6931087 8958551 92447144407682
9382485 798996...

output:

No
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 100000 tokens

Test #14:

score: 0
Accepted
time: 25ms
memory: 2304kb

input:

100000
461078387 667355286 456090624919430375
23604417 712779052 165726350510651084
847344193 747129143 391621108637132344
423449089 527667332 949130632877632354
688120395 148780459 11178117866347735
934374331 115501564 62664484539924189
420761927 864551062 326392808851216988
558273922 39027397 7738...

output:

No
No
Yes
No
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
No
Yes
Yes
No
Yes
No
No
N...

result:

ok 100000 tokens

Test #15:

score: 0
Accepted
time: 7ms
memory: 2048kb

input:

100000
10 9 36
7 10 55
8 5 8
2 9 3
8 3 10
6 1 3
6 7 19
10 1 10
6 7 25
10 9 44
8 9 1
4 7 15
6 5 22
10 7 27
2 5 9
7 2 1
8 3 8
3 10 12
7 8 36
2 9 9
9 4 5
9 7 10
3 2 5
7 4 11
8 7 10
5 2 3
8 7 31
9 8 47
8 3 9
7 2 13
9 10 64
5 1 3
8 9 72
7 6 24
3 7 7
3 4 5
3 7 6
8 3 13
8 3 5
10 3 23
8 5 2
3 8 23
7 10 39
7...

output:

Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
...

result:

ok 100000 tokens

Test #16:

score: 0
Accepted
time: 13ms
memory: 2048kb

input:

100000
734 721 373447
803 570 401747
151 173 3701
99 158 14869
223 992 51086
128 675 60043
37 515 6261
920 643 45677
607 246 936
922 153 80153
963 845 593941
525 898 188877
471 734 318944
401 155 55627
416 587 191670
646 835 185325
115 263 19083
526 965 498547
747 968 31272
485 58 15152
939 1000 426...

output:

No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
Yes
No
Yes
No
No
No
No
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
Yes
No
Yes
Yes
No
Yes
No
No
No
No
No
Yes
No
Yes
No
Yes
Yes
No
No
...

result:

ok 100000 tokens

Test #17:

score: 0
Accepted
time: 18ms
memory: 2176kb

input:

100000
32231 92266 2770604371
42230 96003 1253951600
80182 12377 827385757
31033 52983 1095808654
62119 12786 635278912
47041 95623 2067395761
31597 62488 1652195503
68149 95382 4407733940
43779 23956 562607488
42079 13667 395168791
74808 71447 4494553094
30403 25937 4720828
23049 52477 1130024512
9...

output:

No
Yes
No
No
No
No
No
No
Yes
No
No
Yes
No
Yes
Yes
No
No
No
No
No
Yes
No
Yes
No
No
Yes
Yes
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
Yes
N...

result:

ok 100000 tokens

Test #18:

score: 0
Accepted
time: 23ms
memory: 2176kb

input:

100000
3810923 5708808 14932360854078
5965262 5386583 22172020281391
3844735 7834949 5127417513547
4252291 1624223 3450294524379
2457933 4620706 1312190182588
7466255 9990183 67111186895123
7441773 6851918 16109177647669
4360951 5147843 21136086794083
6931087 8958551 8615586618510
9382485 7989964 42...

output:

Yes
No
Yes
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
No
No
Yes
Yes
Ye...

result:

ok 100000 tokens

Test #19:

score: 0
Accepted
time: 26ms
memory: 2176kb

input:

100000
461078387 667355286 302028648423356735
23604417 712779052 533021022937096
847344193 747129143 161639078989616557
423449089 527667332 22482850933355366
688120395 148780459 25626397068165945
934374331 115501564 19049475390517885
420761927 864551062 272293012993870622
177609799 212880817 1464426...

output:

No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
No
No
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes...

result:

ok 100000 tokens

Test #20:

score: 0
Accepted
time: 0ms
memory: 2304kb

input:

1
1000000000 1 1000000000000000000

output:

No

result:

ok "No"

Test #21:

score: 0
Accepted
time: 0ms
memory: 2176kb

input:

1
3 1000000000 1000000000000000000

output:

No

result:

ok "No"

Extra Test:

score: 0
Extra Test Passed