結果
| 問題 |
No.1250 汝は倍数なりや?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-10 00:18:16 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 1,000 ms |
| コード長 | 2,660 bytes |
| コンパイル時間 | 11,774 ms |
| コンパイル使用メモリ | 376,812 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 14:55:15 |
| 合計ジャッジ時間 | 13,270 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
#![allow(unused_imports)]
use {std::cmp::*, std::collections::*, std::io::Write, std::ops::*};
#[allow(unused_macros)]
macro_rules !dbg {($($e :expr ) ,*) =>{#[cfg (debug_assertions ) ] $({let (e ,mut err ) =(stringify !($e ) ,std ::io ::stderr () ) ;writeln !(err ,"{} = {:?}" ,e ,$e ) .unwrap () } ) *} ;}
#[allow(unused_macros)]
macro_rules !min {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::min ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::min ($a ,min !($($rest ) ,+) ) } } ;}
#[allow(unused_macros)]
macro_rules !chmin {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_min =min !($($cmps ) ,+) ;if $base >cmp_min {$base =cmp_min ;true } else {false } } } ;}
#[allow(unused_macros)]
macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;}
#[allow(unused_macros)]
macro_rules !chmax {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_max =max !($($cmps ) ,+) ;if $base <cmp_max {$base =cmp_max ;true } else {false } } } ;}
#[allow(dead_code)]
mod scanner {
use std;
use std::io::Read;
use std::str::FromStr;
use std::str::SplitWhitespace;
pub struct Scanner<'a> {
it: SplitWhitespace<'a>,
}
impl<'a> Scanner<'a> {
pub fn new(s: &'a String) -> Scanner<'a> {
Scanner {
it: s.split_whitespace(),
}
}
pub fn next<T: FromStr>(&mut self) -> T {
match self.it.next().unwrap().parse::<T>() {
Ok(v) => v,
_ => panic!("Scanner error"),
}
}
pub fn next_chars(&mut self) -> Vec<char> {
self.next::<String>().chars().collect()
}
pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
(0..len).map(|_| self.next()).collect()
}
}
pub fn read_string() -> String {
let mut s = String::new();
std::io::stdin().read_to_string(&mut s).unwrap();
s
}
}
fn main() {
let sc = scanner::read_string();
let mut sc = scanner::Scanner::new(&sc);
let out = std::io::stdout();
let mut out = std::io::BufWriter::new(out.lock());
let n: usize = sc.next();
let h: i64 = sc.next();
let a: Vec<i64> = sc.next_vec(n);
let mut am = a[0].abs();
am %= h;
for i in 1..n {
if am == 0 {
break;
}
am *= a[i].abs();
am %= h;
}
if am == 0 {
writeln!(out, "YES").unwrap();
} else {
writeln!(out, "NO").unwrap();
}
}