結果
| 問題 | No.1611 Minimum Multiple with Double Divisors | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-11-07 23:35:01 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 189 ms / 2,000 ms | 
| コード長 | 1,258 bytes | 
| コンパイル時間 | 16,163 ms | 
| コンパイル使用メモリ | 404,400 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-21 06:41:52 | 
| 合計ジャッジ時間 | 23,565 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 37 | 
ソースコード
const SIZE: usize = 31;
fn solve(factors: &Vec<Vec<usize>>) -> usize {
    let mut x = String::new();
    std::io::stdin().read_line(&mut x).ok();
    let x: usize = x.trim().parse().unwrap();
    let mut xfactors = vec![0usize; SIZE+1];
    let mut target = x;
    for i in 2..=SIZE {
        while target % i == 0 {
            target /= i;
            xfactors[i] += 1;
        }
    }
    for i in 2..=SIZE {
        let mut xcnt = 1usize;
        let mut fcnt = 1usize;
        for j in 2..=i {
            xcnt *= xfactors[j] + 1;
            fcnt *= xfactors[j] + factors[i][j] + 1;
        }
        if xcnt * 2 == fcnt {
            return x * i;
        }
    }
    x
}
fn main() {
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let t: usize = t.trim().parse().unwrap();
    let mut result = Vec::with_capacity(t);
    let mut factors = vec!{vec![0usize; SIZE+1]; SIZE+1};
    for i in 2..=SIZE {
        let mut target = i;
        for j in 2..=SIZE {
            while target % j == 0 {
                target /= j;
                factors[i][j] += 1;
            }
        }
    }
    for _ in 0..t {
        result.push(solve(&factors));
    }
    for &v in result.iter() {
        println!("{}", v);
    }
}
            
            
            
        