結果
| 問題 |
No.2351 Butterfly in Summer
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-06-16 21:29:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 1,024 ms |
| コンパイル使用メモリ | 101,820 KB |
| 最終ジャッジ日時 | 2025-02-14 04:27:10 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
using namespace std;
using ll = long long;
const ll modc=998244353;
ll mod_exp(ll b, ll e, ll m){
if (e > 0 && b == 0) return 0;
ll ans = 1;
b %= m;
while (e > 0){
if ((e & 1LL)) ans = (ans * b) % m;
e = e >> 1LL;
b = (b*b) % m;
}
return ans;
}
int main(){
ll K, N, a;
cin >> N >> K;
a = mod_exp(K, N-1, modc);
cout << (K-1) * N % modc * mod_exp(a, modc-2, modc)% modc << endl;
return 0;
}
srjywrdnprkt