結果
問題 | No.1611 Minimum Multiple with Double Divisors |
ユーザー | fukafukatani |
提出日時 | 2021-07-21 22:40:20 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,142 bytes |
コンパイル時間 | 13,920 ms |
コンパイル使用メモリ | 375,744 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-17 19:42:35 |
合計ジャッジ時間 | 27,491 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 237 ms
10,752 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
コンパイルメッセージ
warning: unused label --> src/main.rs:21:5 | 21 | 'outer: for i in 0..t { | ^^^^^^ | = note: `#[warn(unused_labels)]` on by default warning: unused variable: `i` --> src/main.rs:21:17 | 21 | 'outer: for i in 0..t { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default warning: function `read_vec` is never used --> src/main.rs:86:4 | 86 | fn read_vec<T: std::str::FromStr>() -> Vec<T> { | ^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let t = read::<usize>(); let primes = get_primes(400000); 'outer: for i in 0..t { let x = read::<i64>(); let mut cand = 0; for &p in &primes { if x % p != 0 { cand = p; break; } } let fact = factorize(x, &primes); for (k, v) in fact { cand = min(cand, k.pow(v as u32 + 1)); } println!("{}", cand * x); } } fn factorize(mut num: i64, primes: &Vec<i64>) -> std::collections::HashMap<i64, i64> { // max_primes >= (num)^(1/2) let num_org = num; let mut dict = std::collections::HashMap::new(); for &p in primes.iter() { while num % p == 0 { *dict.entry(p).or_insert(0) += 1; num /= p; } if num == 1 { break; } if p * p > num_org { *dict.entry(num).or_insert(0) += 1; break; } } if num != 1 { dict.insert(num, 1); } dict } fn get_primes(n: i64) -> Vec<i64> { let mut is_prime = vec![true; n as usize + 1]; let mut primes = Vec::new(); is_prime[0] = false; is_prime[1] = false; for i in 2..n + 1 { if is_prime[i as usize] { primes.push(i); let mut j = 2 * i; while j <= n { is_prime[j as usize] = false; j += i; } } } primes } 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() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }