結果

問題 No.2351 Butterfly in Summer
ユーザー kumakumakumakuma
提出日時 2023-05-13 22:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 197,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 18:40:52
合計ジャッジ時間 3,778 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = 3.141592653589793238462643383279;

ll mod = 998244353;
//=============modinv============================
ll modinv(ll a, ll m = mod) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  ll ans = K * (K - 1) % mod;
  for (ll i = 0; i < N; ++i) {
    ans *= modinv(K);
    ans %= mod;
  }
  ans = ans * N % mod;
  cout << ans << "\n";
}
0