結果
問題 | No.2048 L(I+D)S |
ユーザー |
![]() |
提出日時 | 2024-12-30 14:43:14 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 884 bytes |
コンパイル時間 | 7,422 ms |
コンパイル使用メモリ | 272,720 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 14:43:23 |
合計ジャッジ時間 | 9,155 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
//A tree without skin will surely die.//A man without face will be alive.#include<bits/stdc++.h>using namespace std;#define int long long#define rep(i,j,k) for(int i=j;i<=k;++i)#define per(i,j,k) for(int i=j;i>=k;--i)#define add(x,y) (x=((x+y>=mod)?(x+y-mod):(x+y)))int const N=1e5+10,mod=998244353;int n,ans,fac[N],inv[N];inline int qpow(int a,int b){int res=1;while (b){if (b&1) res*=a,res%=mod;a*=a,a%=mod,b>>=1;}return res;}inline void solve(){cin>>n;rep(A,2,n-2){int B=n-A,val=fac[n]*inv[A-2]%mod*inv[B-2]%mod*qpow(n-1,mod-2)%mod*qpow(A,mod-2)%mod*qpow(B,mod-2)%mod;add(ans,val*val%mod);}cout<<ans<<'\n';}signed main(){ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);fac[0]=1;rep(i,1,N-1) fac[i]=fac[i-1]*i%mod;inv[N-1]=qpow(fac[N-1],mod-2);per(i,N-2,0) inv[i]=inv[i+1]*(i+1)%mod;int t=1;// cin>>t;while (t--) solve();return 0;}