結果

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

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#define M 998244353
using namespace std;
int add(int x, int y){x += y;return x >= M? x - M : x;}
int mul(int x, int y){return 1ll * x * y % M;}
int pw2(int x){return mul(x, x);}
template <typename... Args> int mul(int x, int y, int z, Args... arg){return mul(mul(x, y), z, arg...);}
int n, rs, fc[100010], iv[100010], ivfc[100010];
int main(){
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
cin >> n;fc[0] = fc[1] = ivfc[0] = ivfc[1] = iv[1] = 1;
for (int i = 2; i <= n; ++i)fc[i] = mul(fc[i - 1], i), iv[i] = mul(iv[M % i], M - M / i), ivfc[i] = mul(ivfc[i - 1], iv[i]);
for (int A = 2, B = n - 2; B >= 2; ++A, --B)rs = add(rs, pw2(mul(fc[n], ivfc[A - 2], ivfc[B - 2], iv[A], iv[B], iv[n - 1])));
cout << rs << endl; return 0;
}
/*
4 4
2 0
2143 634982576
*/
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0