結果

問題 No.2048 L(I+D)S
ユーザー maksimmaksim
提出日時 2023-02-24 19:05:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 165,720 KB
実行使用メモリ 8,300 KB
最終ジャッジ日時 2023-10-11 04:01:51
合計ジャッジ時間 6,870 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 190 ms
8,020 KB
testcase_01 AC 191 ms
8,088 KB
testcase_02 AC 190 ms
8,056 KB
testcase_03 AC 190 ms
8,048 KB
testcase_04 AC 190 ms
8,052 KB
testcase_05 AC 190 ms
8,028 KB
testcase_06 AC 190 ms
8,028 KB
testcase_07 AC 190 ms
8,300 KB
testcase_08 AC 192 ms
8,028 KB
testcase_09 AC 190 ms
8,036 KB
testcase_10 AC 191 ms
8,020 KB
testcase_11 AC 192 ms
8,088 KB
testcase_12 AC 191 ms
8,104 KB
testcase_13 AC 191 ms
8,148 KB
testcase_14 AC 191 ms
8,240 KB
testcase_15 AC 191 ms
8,020 KB
testcase_16 AC 191 ms
8,076 KB
testcase_17 AC 191 ms
8,060 KB
testcase_18 AC 192 ms
8,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*u)%p;} else {int u=po(a,b-1);return (a*u)%p;}}
int inv(int x) {return po(x,p-2);}
const int maxn=2e5+5;
int fact[maxn];int invf[maxn];int invm[maxn];
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    fact[0]=1;for(int i=1;i<maxn;++i) fact[i]=(fact[i-1]*i)%p;
    for(int i=0;i<maxn;++i) invf[i]=inv(fact[i]);
    for(int i=0;i<maxn;++i) invm[i]=inv(i);
    int n;cin>>n;
    if(n<=3) {cout<<0;return 0;}
    int res=0;
    for(int a=2;a<=n-2;++a)
    {
        int b=n-a;
        int ans=fact[n];
        ans*=invf[a-2];ans%=p;ans*=invf[b-2];ans%=p;
        ans*=invm[a];ans%=p;ans*=invm[b];ans%=p;
        ans*=invm[n-1];ans%=p;ans*=ans;ans%=p;
        res+=ans;res%=p;
    }
    cout<<(res%p+p)%p;
    return 0;
}
0