結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー fukafukatanifukafukatani
提出日時 2021-07-21 22:16:05
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,677 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 145,184 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-24 18:15:45
合計ジャッジ時間 24,237 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,056 ms
4,376 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 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused label
  --> Main.rs:21:5
   |
21 |     'outer: for i in 0..t {
   |     ^^^^^^
   |
   = note: `#[warn(unused_labels)]` on by default

warning: unused variable: `i`
  --> 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
  --> Main.rs:66:4
   |
66 | fn read_vec<T: std::str::FromStr>() -> Vec<T> {
   |    ^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 3 warnings emitted

ソースコード

diff #

#![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(100000);
    'outer: for i in 0..t {
        let x = read::<i128>();
        let mut cand = std::i128::MAX / 100;
        for &p in &primes {
            let mut cur = p;
            for _ in 0..20 {
                if cur > cand {
                    break;
                }
                if x % cur != 0 {
                    cand = min(cur, cand);
                    break;
                }
                cur *= p;
            }
        }
        println!("{}", x * cand);
    }
}

fn get_primes(n: i128) -> Vec<i128> {
    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()
}
0