結果
問題 | No.1250 汝は倍数なりや? |
ユーザー | cympfh |
提出日時 | 2020-10-09 21:23:10 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,766 bytes |
コンパイル時間 | 12,706 ms |
コンパイル使用メモリ | 377,788 KB |
実行使用メモリ | 14,080 KB |
最終ジャッジ日時 | 2024-07-20 08:09:15 |
合計ジャッジ時間 | 15,047 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | AC | 1 ms
5,376 KB |
testcase_49 | AC | 1 ms
5,376 KB |
testcase_50 | AC | 1 ms
5,376 KB |
testcase_51 | AC | 1 ms
5,376 KB |
ソースコード
#![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<Output = Self> + std::ops::AddAssign + std::ops::Sub<Output = Self> + std::ops::SubAssign + std::ops::Mul<Output = Self> + std::ops::Div<Output = Self> + std::ops::Rem<Output = Self> { } 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<N: Nat>(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<String>, } impl Scanner { fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new(), } } fn cin<T: FromStr>(&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::<T>().ok().unwrap() } fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() } fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() } }