题解:P11075 不等关系 加强版

· · 题解

对于任意一个 n + 1 的排列 p,不难发现有且仅有一个 s 是满足 p 被贡献入 f(s) 的计算的。例如 p=[1,3,2] 仅对应一个 s = [\texttt <,\texttt>]。

也就是如果我们从贡献的角度考虑,每个排列都被贡献进了答案恰好 1 次。而排列总共有 (n+1)! 个,每个贡献 1,所以答案为 (n+1)!。

#include <bits/stdc++.h>

using namespace std;

signed main() {
    int n, res = 1;
    cin >> n;
    n ++ ;
    for (int i = 1; i <= n; ++ i ) res = 1ll * i * res % 998244353;
    cout << res;
    return 0;
}