結果
問題 | No.2351 Butterfly in Summer |
ユーザー |
![]() |
提出日時 | 2023-06-16 21:27:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 895 bytes |
コンパイル時間 | 1,876 ms |
コンパイル使用メモリ | 192,964 KB |
最終ジャッジ日時 | 2025-02-14 04:23:41 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } ll modpow(ll a,ll b,ll mod){ if(mod==1) return 0; if(b==0) return 1; ll p=a,ret=1; for(ll i=0;i<=62;i++){ if(b&(1ll<<i)){ ret*=p; ret%=mod; } p=(p%mod)*(p%mod); p%=mod; } return ret; } ll division(ll a,ll b,ll mod){ return (a*modpow(b,mod-2,mod))%mod; } int main(){ ios::sync_with_stdio(false); const ll mod=998244353; ll n,k; cin >> n >> k; cout << division(k*n*(k-1)%mod,modpow(k,n,mod),mod) << '\n'; }