結果

問題 No.2351 Butterfly in Summer
ユーザー GEX777GEX777
提出日時 2023-06-16 21:32:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 12,534 bytes
コンパイル時間 3,675 ms
コンパイル使用メモリ 204,120 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 13:09:13
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #
プレゼンテーションモードにする

/**
* @file template.cpp
* @brief
* @author Gex777
* @date update:2023/04/21
*/
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <sstream>
#include <climits>
#include <bitset>
#include <deque>
#include <cassert>
#include <list>
#include <queue>
#include <valarray>
#include <complex>
#include <bitset>
#include <atcoder/all> //ACL
using namespace std;
using namespace atcoder;
//
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
using AdjacencyList = map<int, vi>;
using EdgeAdjacencyList = map<int, vector<int, int>>;
//
#define all(x) x.begin(), x.end()
//
constexpr double PI = 3.141592653589793;
constexpr ll MOD998 = 998244353;
constexpr ll MOD107 = 1000000007;
/****************************************************
***************************
****************************************************/
// , 1, debug
template <typename T>
void printv(T &a)
{
for (const auto &x : a)
{
cout << x << " ";
}
puts("");
return;
}
// ,
template <typename T>
void printvv(T &a)
{
for (const auto &x : a)
{
printv(x);
}
}
// , pair
template <typename T>
void print_vpair(const T &a)
{
for (const auto &x : a)
{
cout << "(" << x.first << ", " << x.second << "), ";
}
puts("");
return;
}
template <class T>
inline bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
// , , debug
template <typename T>
void println(T &a)
{
for (const auto &x : a)
{
cout << x << endl;
}
return;
}
// 1~N
ll sum_from_1_to_N(ll N)
{
if (N < 1LL)
{
return 0;
}
if ((N & 1) == 0) // even
{
return N / 2 * (N + 1);
}
else // odd
{
return (N + 1) / 2 * N;
}
}
// A~N
ll sum_from_A_to_B(ll A, ll B)
{
return sum_from_1_to_N(B) - sum_from_1_to_N(A);
}
// a^b, 2,3Mod
ll intPowMod(ll a, ll b, const ll MOD = LLONG_MAX)
{
ll ans = 1;
ll A = a;
while (b > 0)
{
int n = b % 2;
b /= 2;
if (n == 1)
{
ans *= A % MOD;
ans %= MOD;
}
A = ((A % MOD) * (A % MOD)) % MOD;
}
return ans;
}
ld arg_to_rad(ld arg)
{
return (arg * PI / 180.0);
}
ld rad_to_arg(ld rad)
{
return rad * 180.0 / PI;
}
// C(n, m)
ll combination(const ll n, const ll m)
{
assert(n >= m); // n>=m
ll up = 1;
ll down = 1;
for (int i = n; i > n - m; i--)
{
up *= i;
}
for (int i = m; i >= 2; i--)
{
down *= i;
}
return up / down;
}
// ,O(N**2)
vvll combination_table(const int MAX_N = 50)
{
vvll com = vvll(MAX_N + 1, vll(MAX_N + 1, 0)); //
com[0][0] = 1;
for (int i = 1; i <= MAX_N; ++i)
{
com[i][0] = 1;
for (int j = 1; j <= MAX_N; j++)
{
com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]);
}
}
return com;
}
// a÷bMOD
ll DivisionMod(ll a, ll b, ll MOD)
{
return (a * intPowMod(b, MOD - 2, MOD)) % MOD;
}
// C(n, r)Mod, 3Conbination
ll combinationMod(ll n, ll r, ll MOD = LLONG_MAX)
{
// up
ll up = 1;
for (ll i = n - r + 1; i <= n; ++i)
{
up = (up * i) % MOD;
}
// down
ll down = 1;
for (ll i = 1; i <= r; ++i)
down = (down * i) % MOD;
return DivisionMod(up, down, MOD);
}
// a,b, A>=B>=0, O(logB)
long long GCD(long long a, long long b)
{
if (b == 0)
return a;
else
return GCD(b, a % b);
}
// , : a b
// ax + by = gcd(a, b) (x, y)
long long extGCD(long long a, long long b, long long &x, long long &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
long long d = extGCD(b, a % b, y, x);
y -= a / b * x;
return d;
}
//
ll LCM(ll a, ll b)
{
return a * b / GCD(a, b);
}
// , P->true, not_P->false
bool check_Prime(ll N)
{
if (N == 2)
return true;
if (N == 1 || (N & 1) == 0)
return false;
for (ll i = 3; i <= sqrt(N); i += 2)
{
if (N % i == 0)
return false;
}
return true;
}
// ,key:, value:map<ll,ll>
map<ll, ll> prime_factorize(ll number)
{
map<ll, ll> table;
for (ll i = 2; i * i <= number; ++i)
{
while (number % i == 0)
{
table[i]++;
number /= i;
}
}
if (number != 1LL)
{
table[number]++;
}
return table;
}
/* and
prime->IsPrime[i]=i; not prime -> */
vi Eratosthenes(size_t max_number)
{
vi IsPrime(max_number + 1);
// table
for (int i = 1; i < IsPrime.size(); ++i)
{
IsPrime[i] = i;
}
for (int i = 2; i <= sqrt(max_number); ++i)
{
for (int j = i; j <= max_number; j += i)
{
if (IsPrime[j] == j)
{
IsPrime[j] = i;
}
}
}
return IsPrime;
}
// O(N)N
ll factorial(const ll N)
{
ll ans = 1;
for (ll i = 1; i <= N; ++i)
{
ans *= i;
}
return ans;
}
// Run Length Encoding,
template <typename T>
vector<pair<T, int>> RLE(const vector<T> &A)
{
vector<pair<T, int>> rle;
rle.push_back({A.front(), 1});
for (int i = 1; i < A.size(); ++i)
{
if (rle.back().first == A[i])
{
rle.back().second++;
}
else
{
rle.push_back({A[i], 1});
}
}
return rle;
}
vector<pair<char, int>> RLE(const string &S)
{
vector<pair<char, int>> rle;
rle.push_back({S.front(), 1});
for (int i = 1; i < S.size(); ++i)
{
if (rle.back().first == S[i])
{
rle.back().second++;
}
else
{
rle.push_back({S[i], 1});
}
}
return rle;
}
void DEBUG_INDICATE()
{
static int cnt = 0;
cout << "-----DEBUG:" << cnt++ << "------" << endl;
return;
}
/* RMQ[0,n-1]
update(i,x): i x O(log(n))
query(a,b): [a,b) O(log(n))
*/
template <typename T>
struct RangeMinimumQuery
{
const T INF = numeric_limits<T>::max();
int n; //
vector<T> dat; //
RangeMinimumQuery(int n_) : n(), dat(n_ * 4, INF)
{ // 2^x
int x = 1;
while (n_ > x)
{
x *= 2;
}
n = x;
}
void update(int i, T x)
{
i += n - 1;
dat[i] = x;
while (i > 0)
{
i = (i - 1) / 2; // parent
dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
}
}
// the minimum element of [a,b)
T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
T query_sub(int a, int b, int k, int l, int r)
{
if (r <= a || b <= l)
{
return INF;
}
else if (a <= l && r <= b)
{
return dat[k];
}
else
{
T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
return min(vl, vr);
}
}
};
/* RMQ[0,n-1]
update(i,x): i x O(log(n))
query(a,b): [a,b) O(log(n))
*/
template <typename T>
struct RangeMaximumQuery
{
const T INF = numeric_limits<T>::min();
int n; //
vector<T> dat; //
RangeMaximumQuery(int n_) : n(), dat(n_ * 4, INF)
{ // 2^x
int x = 1;
while (n_ > x)
{
x *= 2;
}
n = x;
}
void update(int i, T x)
{
i += n - 1;
dat[i] = x;
while (i > 0)
{
i = (i - 1) / 2; // parent
dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
}
}
// the minimum element of [a,b)
T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
T query_sub(int a, int b, int k, int l, int r)
{
if (r <= a || b <= l)
{
return INF;
}
else if (a <= l && r <= b)
{
return dat[k];
}
else
{
T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl, vr);
}
}
};
// Union-Find
struct UnionFind
{
vector<int> par, rank, siz;
//
UnionFind(int n) : par(n, -1), rank(n, 0), siz(n, 1) {}
//
int root(int x)
{
if (par[x] == -1)
return x; // x x
else
return par[x] = root(par[x]); //
}
// x y (= )
bool issame(int x, int y)
{
return root(x) == root(y);
}
// x y
bool unite(int x, int y)
{
int rx = root(x), ry = root(y); // x y
if (rx == ry)
return false; //
// union by rank
if (rank[rx] < rank[ry])
swap(rx, ry); // ry rank
par[ry] = rx; // ry rx
if (rank[rx] == rank[ry])
rank[rx]++; // rx rank 調
siz[rx] += siz[ry]; // rx siz 調
return true;
}
// x
int size(int x)
{
return siz[root(x)];
}
};
/* BIT:
a_1 = a_2 = ... = a_n = 0
O(logn)
*/
template <typename T>
struct BIT
{
int n; // (+1)
vector<T> bit; //
//
BIT(int n_) : n(n_ + 1), bit(n, 0) {}
// add(i,x): a_i += x
void add(int i, T x)
{
for (int idx = i; idx < n; idx += (idx & -idx))
{
bit[idx] += x;
}
}
// sum(i): a_1 + a_2 + ... + a_i
T sum(int i)
{
T s(0);
for (int idx = i; idx > 0; idx -= (idx & -idx))
{
s += bit[idx];
}
return s;
}
};
/*********************************************
*******************************
***********************************************/
int main()
{
using mint = modint998244353;
int N,K;
cin >> N >> K;
mint R = K;
mint Q = N*(K-1);
Q /= R.pow(N-1);
cout << Q.val() << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0