結果

問題 No.2351 Butterfly in Summer
ユーザー atug tokyoatug tokyo
提出日時 2023-06-16 21:34:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,450 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 201,532 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 18:50:39
合計ジャッジ時間 3,091 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/modint>

using namespace std;
using ll = long long;
using ld = long double;
using mint = atcoder::modint998244353;
using Pair = pair<int, int>;
using Tuple = tuple<int, int, int>;
using VI1 = vector<int>;
using VI2 = vector<VI1>;
using VL1 = vector<ll>;
using VL2 = vector<VL1>;
using VD1 = vector<ld>;
using VD2 = vector<VD1>;
using VB1 = vector<bool>;
using VB2 = vector<VB1>;
using VP1 = vector<Pair>;
using VP2 = vector<VP1>;
using VT1 = vector<Tuple>;
using VT2 = vector<VT1>;
using VM1 = vector<mint>;
using VM2 = vector<VM1>;
using Queue = queue<int>;
using DQ = deque<int>;
using PQ = priority_queue<int, vector<int>, greater<int>>;
using Table = VI2;
using Graph = VI2;

/** io */
template <typename T>
std::vector<T> input_vec(int N);
template <typename T>
void output_row(std::vector<T> &row);
template <typename T>
void output_col(std::vector<T> &col);
void outputYesNo(bool yes, const string &Yes = "Yes", const string &No = "No");
/** minmax */
template <typename T>
bool chmin(T &a, T b);
template <typename T>
bool chmax(T &a, T b);

auto solve() {
  int N, K;
  cin >> N >> K;
  mint deno = mint(K).pow(N), nume = mint(K) * N * (K - 1);
  return (nume / deno).val();
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while (t--) {
    auto result = solve();
    cout << result << '\n';
    // output_row(result);
    // output_col(result);
    // outputYesNo(result, "Yes", "No");
  }
}

/** @note 使用頻度が高く毎回貼付するのが面倒なライブラリを実装しておく。*/

template <typename T>
std::vector<T> input_vec(int N) {
  std::vector<T> v(N);
  for (auto &vi : v) {
    cin >> vi;
  }
  return v;
}

void outputYesNo(bool yes, const string &Yes, const string &No) {
  if (yes)
    cout << Yes << '\n';
  else
    cout << No << '\n';
}

template <typename T>
void output_row(std::vector<T> &row) {
  int N = row.size();
  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << ' ';
    cout << row.at(i);
  }
  cout << '\n';
}

template <typename T>
void output_col(std::vector<T> &col) {
  int N = col.size();
  for (int i = 0; i < N; ++i) {
    cout << col.at(i) << '\n';
  }
}

template <typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
0