結果
| 問題 |
No.1723 [Cherry 3rd Tune *] Dead on
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-30 10:30:19 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,278 bytes |
| コンパイル時間 | 13,757 ms |
| コンパイル使用メモリ | 401,276 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-22 18:41:28 |
| 合計ジャッジ時間 | 15,908 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 WA * 16 |
ソースコード
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");
}
}