結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー fukafukatani
提出日時 2021-07-21 23:41:07
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 1,114 bytes
コンパイル時間 12,400 ms
コンパイル使用メモリ 380,860 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-03 02:39:36
合計ジャッジ時間 18,132 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let t = read::<usize>();

    let mut cand_count = vec![vec![0i64; 33]; 33];
    for cand in 2..33 {
        let mut c = cand;
        for i in 2..33 {
            while c % i == 0 {
                cand_count[cand][i as usize] += 1;
                c /= i;
            }
        }
    }

    for _ in 0..t {
        let x = read::<i64>();

        let mut count = vec![0i64; 33];
        let mut c = x;
        for i in 2..33 {
            while c % i == 0 {
                count[i as usize] += 1;
                c /= i;
            }
        }
        let p = count.iter().map(|&x| x + 1).product::<i64>();
        for cand in 2..33 {
            let q = count
                .iter()
                .zip(cand_count[cand].iter())
                .map(|(&x, &y)| x + y + 1)
                .product::<i64>();
            if q == p * 2 {
                println!("{}", cand as i64 * x);
                break;
            }
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
0