結果

問題 No.882 約数倍数
ユーザー phspls
提出日時 2020-01-13 17:21:26
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 500 ms
コード長 599 bytes
コンパイル時間 12,998 ms
コンパイル使用メモリ 401,084 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-18 01:04:18
合計ジャッジ時間 14,009 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn solve(a: usize, b: usize) {
    let divisors: Vec<usize> = (1..=a).filter(|i| a % i == 0).collect();
    let yes: bool = (1..=100)
        .filter(|i| i % b == 0)
        .any(|i| divisors.contains(&i));
    if yes {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}

fn main() {
    let mut ab = String::new();
    std::io::stdin().read_to_string(&mut ab).ok();
    let ab: Vec<usize> = ab.trim().split('\n').next().unwrap().trim().split_whitespace()
        .map(|i| i.parse::<usize>().unwrap())
        .collect();
    solve(ab[0], ab[1]);
}
0