結果

問題 No.1330 Multiply or Divide
ユーザー KoDKoD
提出日時 2021-01-08 21:41:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,169 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 77,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 02:32:04
合計ジャッジ時間 3,413 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 60 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 32 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 73 ms
5,376 KB
testcase_09 AC 76 ms
5,376 KB
testcase_10 AC 74 ms
5,376 KB
testcase_11 AC 86 ms
5,376 KB
testcase_12 AC 90 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 71 ms
5,376 KB
testcase_19 AC 71 ms
5,376 KB
testcase_20 AC 70 ms
5,376 KB
testcase_21 AC 71 ms
5,376 KB
testcase_22 AC 70 ms
5,376 KB
testcase_23 AC 78 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 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 2 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 53 ms
5,376 KB
testcase_35 AC 18 ms
5,376 KB
testcase_36 AC 47 ms
5,376 KB
testcase_37 AC 42 ms
5,376 KB
testcase_38 AC 27 ms
5,376 KB
testcase_39 AC 19 ms
5,376 KB
testcase_40 AC 22 ms
5,376 KB
testcase_41 AC 13 ms
5,376 KB
testcase_42 AC 39 ms
5,376 KB
testcase_43 AC 45 ms
5,376 KB
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>
#include <cassert>

#line 2 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/cpp_programming/Library/other/range.cpp"

class range {
  struct iter {
    std::size_t itr;
    constexpr iter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { ++itr; }
    constexpr bool operator != (iter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  struct reviter {
    std::size_t itr;
    constexpr reviter(std::size_t pos) noexcept: itr(pos) { }
    constexpr void operator ++ () noexcept { --itr; }
    constexpr bool operator != (reviter other) const noexcept { return itr != other.itr; }
    constexpr std::size_t operator * () const noexcept { return itr; }
  };

  const iter first, last;

public:
  constexpr range(std::size_t first, std::size_t last) noexcept: first(first), last(std::max(first, last)) { }
  constexpr iter begin() const noexcept { return first; }
  constexpr iter end() const noexcept { return last; }
  constexpr reviter rbegin() const noexcept { return reviter(*last - 1); } 
  constexpr reviter rend() const noexcept { return reviter(*first - 1); } 
};

/**
 * @title Range
 */
#line 15 "main.cpp"

using i32 = std::int32_t;
using i64 = std::int64_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr i32 inf32 = (u32) ~0 >> 2;
constexpr i64 inf64 = (u64) ~0 >> 2;

template <class T>
using Vec = std::vector<T>;

int main() {
  usize N;
  u64 M, P;
  std::cin >> N >> M >> P;
  Vec<u64> A(N);
  for (auto &x: A) {
    std::cin >> x;
    while (x % P == 0) {
      x /= P;
    }
  }
  const auto max = *std::max_element(A.begin(), A.end());
  if (max == 1) {
    std::cout << -1 << '\n';
  }
  else {
    u64 cur = 1;
    usize ans = 0;
    while (cur <= M) {
      cur *= max;
      ans += 1;
    }
    std::cout << ans << '\n';
  }
  return 0;
}
0