結果
問題 |
No.1611 Minimum Multiple with Double Divisors
|
ユーザー |
|
提出日時 | 2022-10-25 01:11:37 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 248 ms / 2,000 ms |
コード長 | 1,288 bytes |
コンパイル時間 | 11,382 ms |
コンパイル使用メモリ | 391,308 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 03:35:19 |
合計ジャッジ時間 | 18,129 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 37 |
ソースコード
const LIMIT: usize = 31; fn solve(cnt_map: &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 cnts = vec![0usize; LIMIT+1]; let mut target = x; for i in 2..=LIMIT { while target % i == 0 { target /= i; cnts[i] += 1; } } for i in 2..=LIMIT { let mut org = 1usize; let mut times = 1usize; for j in 2..=LIMIT { org *= cnts[j] + 1; times *= cnts[j] + 1 + cnt_map[i][j]; } if org * 2 == times { return i * x; } } LIMIT * x } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut result = Vec::with_capacity(n); let mut cnt_map = vec![vec![0usize; LIMIT+1]; LIMIT+1]; for i in 2..=LIMIT { let mut base = i; for j in 2..=i { while base % j == 0 { base /= j; cnt_map[i][j] += 1; } if base == 1 { break; } } } for _ in 0..n { result.push(solve(&cnt_map)); } for &v in result.iter() { println!("{}", v); } }