結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー phsplsphspls
提出日時 2022-09-30 10:30:19
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,278 bytes
コンパイル時間 11,374 ms
コンパイル使用メモリ 402,084 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-02 02:22:09
合計ジャッジ時間 13,415 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 13 ms
5,376 KB
testcase_05 AC 8 ms
5,376 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 17 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 9 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 3 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 7 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 19 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 17 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 20 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 18 ms
5,376 KB
testcase_33 AC 10 ms
5,376 KB
testcase_34 WA -
testcase_35 AC 10 ms
5,376 KB
testcase_36 AC 21 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 5 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 WA -
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 1 ms
5,376 KB
testcase_45 AC 5 ms
5,376 KB
testcase_46 WA -
testcase_47 AC 7 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;


fn main() {
    let mut xayb = String::new();
    std::io::stdin().read_line(&mut xayb).ok();
    let xayb: Vec<usize> = xayb.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let x = xayb[0];
    let a = xayb[1];
    let y = xayb[2];
    let b = xayb[3];

    if y == 1 {
        println!("Yes");
        return;
    }
    let mut xfactors = HashMap::new();
    let mut yfactors = HashMap::new();
    let mut xtarget = x;
    let mut ytarget = y;
    for i in 2..=(x as f64).sqrt().floor() as usize {
        while xtarget % i == 0 {
            xtarget /= i;
            *xfactors.entry(i).or_insert(0usize) += 1;
        }
    }
    if xtarget > 1 { xfactors.insert(xtarget, 1); }
    for i in 2..=(y as f64).sqrt().floor() as usize {
        while ytarget % i == 0 {
            ytarget /= i;
            *yfactors.entry(i).or_insert(0usize) += 1;
        }
    }
    if ytarget > 1 { yfactors.insert(ytarget, 1); }
    let mut flg = true;
    for (&key, &ycnt) in yfactors.iter() {
        if let Some(&xcnt) = xfactors.get(&key) {
            flg &= (xcnt * a) % (ycnt * b) == 0;
        } else {
            flg = false;
        }
    }
    if flg {
        println!("Yes");
    } else {
        println!("No");
    }
}
0