結果
問題 | No.1250 汝は倍数なりや? |
ユーザー |
|
提出日時 | 2022-11-13 18:09:57 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 56 ms / 1,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 15,972 ms |
コンパイル使用メモリ | 379,080 KB |
実行使用メモリ | 5,504 KB |
最終ジャッジ日時 | 2024-09-15 00:11:50 |
合計ジャッジ時間 | 19,254 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:11:9 | 11 | let n = nh[0]; | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
fn gcd(a: isize, b: isize) -> isize { if b == 0 { return a; } gcd(b, a%b) } fn main() { let mut nh = String::new(); std::io::stdin().read_line(&mut nh).ok(); let nh: Vec<usize> = nh.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nh[0]; let h = nh[1] as isize; let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec<isize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); if a.iter().filter(|&&v| v == 0).count() > 0 { println!("YES"); return; } let result = a.iter().map(|&v| gcd(h, v.abs())).fold(1isize, |x, y| gcd(h, x*y)); if result == h { println!("YES"); } else { println!("NO"); } }