#![allow(unused_imports, unused_macros, dead_code)] macro_rules! min { (.. $x:expr) => {{ let mut it = $x.iter(); it.next().map(|z| it.fold(z, |x, y| min!(x, y))) }}; ($x:expr) => ($x); ($x:expr, $($ys:expr),*) => {{ let t = min!($($ys),*); if $x < t { $x } else { t } }} } macro_rules! max { (.. $x:expr) => {{ let mut it = $x.iter(); it.next().map(|z| it.fold(z, |x, y| max!(x, y))) }}; ($x:expr) => ($x); ($x:expr, $($ys:expr),*) => {{ let t = max!($($ys),*); if $x > t { $x } else { t } }} } macro_rules! trace { ($x:expr) => { #[cfg(debug_assertions)] eprintln!(">>> {} = {:?}", stringify!($x), $x) }; ($($xs:expr),*) => { trace!(($($xs),*)) } } macro_rules! flush { () => { std::io::stdout().flush().unwrap(); }; } macro_rules! put { (.. $x:expr) => {{ let mut it = $x.iter(); if let Some(x) = it.next() { print!("{}", x); } for x in it { print!(" {}", x); } println!(""); }}; ($x:expr) => { println!("{}", $x) }; ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) } } const M: i64 = 1_000_000_007; // @num/gcd // @num/base pub trait Zero { fn zero() -> Self; } pub trait One { fn one() -> Self; } pub trait Num: Copy + Eq + Ord + Zero + One + std::marker::Sized + std::ops::Add + std::ops::AddAssign + std::ops::Sub + std::ops::SubAssign + std::ops::Mul + std::ops::Div + std::ops::Rem { } pub trait Int: Num {} pub trait Nat: Num {} macro_rules! define_zero_one { ($ty:ty, $zero:expr, $one:expr) => { impl Zero for $ty { fn zero() -> Self { $zero } } impl One for $ty { fn one() -> Self { $one } } }; } define_zero_one!(usize, 0, 1); define_zero_one!(u32, 0, 1); define_zero_one!(u64, 0, 1); define_zero_one!(u128, 0, 1); define_zero_one!(i32, 0, 1); define_zero_one!(i64, 0, 1); define_zero_one!(i128, 0, 1); define_zero_one!(f32, 0.0, 1.0); define_zero_one!(f64, 0.0, 1.0); impl Num for usize {} impl Num for u32 {} impl Num for u64 {} impl Num for u128 {} impl Num for i32 {} impl Num for i64 {} impl Num for i128 {} impl Nat for usize {} impl Nat for u32 {} impl Nat for u64 {} impl Nat for u128 {} impl Int for i32 {} impl Int for i64 {} impl Int for i128 {} pub fn gcd(a: N, b: N) -> N { if b == N::zero() { a } else { gcd(b, a % b) } } fn main() { let mut sc = Scanner::new(); let n: usize = sc.cin(); let mut h: u64 = sc.cin(); for _ in 0..n { let a: u64 = sc.cin(); h /= gcd(h, a); } put!(if h == 1 { "YES" } else { "NO" }); } use std::collections::VecDeque; use std::io::{self, Write}; use std::str::FromStr; struct Scanner { stdin: io::Stdin, buffer: VecDeque, } impl Scanner { fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new(), } } fn cin(&mut self) -> T { while self.buffer.is_empty() { let mut line = String::new(); let _ = self.stdin.read_line(&mut line); for w in line.split_whitespace() { self.buffer.push_back(String::from(w)); } } self.buffer.pop_front().unwrap().parse::().ok().unwrap() } fn chars(&mut self) -> Vec { self.cin::().chars().collect() } fn vec(&mut self, n: usize) -> Vec { (0..n).map(|_| self.cin()).collect() } }