結果

問題 No.2380 Sylow P-subgroup
ユーザー zer0-starzer0-star
提出日時 2023-07-14 21:31:15
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,870 bytes
コンパイル時間 8,708 ms
コンパイル使用メモリ 179,220 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 11:30:01
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,356 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:52:15: warning: explicit template parameter list for lambdas is a C++20 extension [-Wc++20-extensions]
  [&is, &tpl ]<size_t... I>(std::index_sequence<I...>) {
              ^
1 warning generated.

ソースコード

diff #

#include <bits/extc++.h>

#include <atcoder/all>

#ifdef ONLINE_JUDGE

#include <bits/extc++.h>

#include <atcoder/all>

#else

// #include "all.h"

#endif

using ll = long long int;

template <class T>
bool chmin(T &x, const T val) {
  if (x > val) {
    x = val;
    return true;
  } else {
    return false;
  }
}

template <class T>
bool chmax(T &x, const T val) {
  if (x < val) {
    x = val;
    return true;
  } else {
    return false;
  }
}

template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
  for (T &x : v) is >> x;
  return is;
}

template <class... T>
std::istream &operator>>(std::istream &is, std::tuple<T...> &tpl) {
  [&is, &tpl ]<size_t... I>(std::index_sequence<I...>) {
    (is >> ... >> std::get<I>(tpl));
  }
  (std::make_index_sequence<std::tuple_size_v<std::tuple<T...>>>{});
  return is;
}

template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
  for (int i = 0; i < v.size(); i++)
    os << v[i] << (i == v.size() - 1 ? "" : " ");
  return os;
}

struct Initialization {
  Initialization() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
  }
} initialization;

constexpr std::pair<int, int> dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

template <typename T>
using infs = std::numeric_limits<T>;

template <typename T>
class factorials {
  size_t n;
  std::vector<T> fact, inv_fact;

  void extend(size_t m) {
    if (m <= n) return;
    fact.resize(m + 1);
    inv_fact.resize(m + 1);
    for (size_t i = n + 1; i <= m; i++) fact[i] = fact[i - 1] * i;
    inv_fact[m] = fact[m].inv();
    for (size_t i = m - 1; i >= n + 1; i--) inv_fact[i] = inv_fact[i + 1] * i;
    n = m;
  }

 public:
  factorials() : n(0), fact(1, 1), inv_fact(1, 1) {}

  factorials(size_t n) : n(n), fact(n + 1), inv_fact(n + 1) {
    fact[0] = 1;
    for (size_t i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
    inv_fact[n] = fact[n].inv();
    for (size_t i = n; i >= 1; i--) inv_fact[i - 1] = inv_fact[i] * i;
  }

  T inv(int k) {
    extend(k);
    return inv_fact[k];
  }

  T operator()(int k) {
    extend(k);
    return fact[k];
  }

  T perm(int n, int k) {
    if (n < k) return 0;
    if (k < 0) return 0;
    extend(n);
    return fact[n] * inv_fact[n - k];
  }

  T comb(int n, int k) {
    if (n < k) return 0;
    if (k < 0) return 0;
    extend(n);
    return fact[n] * inv_fact[n - k] * inv_fact[k];
  }
};

template <typename T>
class fps {
  std::vector<T> v;

 public:
  fps(int n) : v(n) {}
  fps(std::vector<T> v) : v(v) {}
};

using mint = atcoder::modint998244353;

int main() {
  ll n, p;
  std::cin >> n >> p;

  ll t = 0;

  while (n > 0) {
    t += n /= p;
  }

  std::cout << mint(p).pow(t).val() << std::endl;
}
0