結果

問題 No.2048 L(I+D)S
ユーザー vjudge1
提出日時 2024-12-30 13:40:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,040 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 68,204 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 13:40:11
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=2e5+100;
const int mod=998244353;
LL n,m;
int fact[N],infact[N];
int qmi(int x,int k){
    int res=1;
    while(k){                   
        if(k&1) res=(LL)res*x%mod;
        x=(LL)x*x%mod;
        k>>=1;
    }
    return res;
}
void init(int n){
    fact[0]=infact[0]=1;
    for(int i=1;i<=n;i++) fact[i]=(LL)fact[i-1]*i%mod;
    infact[n]=qmi(fact[n],mod-2);
    for(int i=n-1;i;i--) infact[i]=(LL)infact[i+1]*(i+1)%mod;
    return;
}
int C(LL n,LL m){
    if(n<m) return 0;
    return (LL)fact[n]*infact[m]%mod*infact[n-m]%mod;
}
int inv(int x){
    return qmi(x,mod-2);
}
void add(int& x,int y){
    x+=y;if(x>=mod) x-=mod;
}
int main(){
    init(N-5);
    scanf("%lld",&n);
    LL res=0;
    for(int i=2;i<n-1;i++){
        LL a=fact[n];
        LL b=(LL)fact[i-2]*fact[n-i-2]%mod*i%mod*(n-i)%mod*(n-1)%mod;
        res=(res+a*a%mod*inv(b)%mod*inv(b))%mod;
    }
    cout<<res%mod<<endl;
    return 0;
}
0