結果

問題 No.1330 Multiply or Divide
ユーザー fukafukatanifukafukatani
提出日時 2021-01-08 21:37:43
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,321 bytes
コンパイル時間 12,904 ms
コンパイル使用メモリ 377,744 KB
実行使用メモリ 6,540 KB
最終ジャッジ日時 2024-04-28 02:23:21
合計ジャッジ時間 15,186 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
6,044 KB
testcase_02 WA -
testcase_03 AC 0 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 10 ms
5,524 KB
testcase_07 WA -
testcase_08 AC 21 ms
6,528 KB
testcase_09 AC 24 ms
6,400 KB
testcase_10 AC 22 ms
6,408 KB
testcase_11 AC 20 ms
6,412 KB
testcase_12 AC 22 ms
6,400 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 19 ms
6,280 KB
testcase_19 AC 18 ms
6,404 KB
testcase_20 AC 18 ms
6,408 KB
testcase_21 AC 19 ms
6,540 KB
testcase_22 AC 18 ms
6,540 KB
testcase_23 AC 19 ms
6,400 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 14 ms
5,524 KB
testcase_35 AC 5 ms
5,376 KB
testcase_36 AC 13 ms
5,376 KB
testcase_37 AC 11 ms
5,376 KB
testcase_38 AC 7 ms
5,376 KB
testcase_39 AC 5 ms
5,376 KB
testcase_40 AC 6 ms
5,376 KB
testcase_41 AC 4 ms
5,376 KB
testcase_42 AC 11 ms
5,376 KB
testcase_43 AC 11 ms
5,376 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
  --> src/main.rs:20:10
   |
20 |     let (n, m, p) = (v[0], v[1], v[2]);
   |          ^ help: if this is intentional, prefix it with an underscore: `_n`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

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 v = read_vec::<i64>();
    let (n, m, p) = (v[0], v[1], v[2]);
    let a = read_vec::<i64>();
    let amax = *a.iter().max().unwrap();
    let mut aa = vec![];
    for mut num in a {
        while num % p == 0 {
            num /= p;
        }
        aa.push(num);
    }
    // debug!(aa);
    let aa_max = *aa.iter().max().unwrap();
    if aa_max == 1 && amax <= m {
        println!("-1");
        return;
    }
    if m == 1 {
        println!("0");
        return;
    }

    let mut x = 1;
    let mut ans = 1;
    while x * amax <= m {
        x *= aa_max;
        ans += 1;
    }
    println!("{}", ans);
}

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