結果
| 問題 |
No.2351 Butterfly in Summer
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-16 21:40:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 1,458 bytes |
| コンパイル時間 | 3,116 ms |
| コンパイル使用メモリ | 161,456 KB |
| 最終ジャッジ日時 | 2025-02-14 04:53:37 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
using mint = modint998244353;
class combination {
public:
vector<mint> fact, ifact;
combination(int n) :fact(n + 1), ifact(n + 1) {
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) const {
if (k < 0 || k > n) return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
mint p(ll n,ll k) const{
if (k < 0 || k > n ) return 0;
return fact[n]*ifact[n-k];
}
mint h(ll n,ll k) const {
if (k < 0 || k > n) return 0;
return fact[n+k-1]*ifact[n-1]*ifact[k];
}
mint choose(ll n ,ll a) const{// k <= 1e5 n <= 1e9
if (a < 0 || a > n) return 0;
mint x=1,y=1;
for(ll i=0;i < a; i++){
x*=n-i;
y*=i+1;
}
return x / y;
}
mint perm(ll n, ll a) const { // k <= 1e5
if (a < 0 || a > n) return 0;
mint x=1,y=1;
for (ll i=0;i < a;i++){
x*=n-i;
}
return x;
}
}comb(100000);// plsese mint control!
int main(){
int n,k;
cin >> n >> k;
mint ans = (comb(n,1)*mint(k)*mint(k-1));
ans /= mint(k).pow(n);
cout << ans.val() << endl;
return 0;
}