QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211911#6736. Alice and BobguichenCompile Error//Python31.2kb2023-10-12 22:57:322023-10-12 22:57:32

Judging History

你现在查看的是最新测评结果

  • [2023-10-12 22:57:32]
  • 评测
  • [2023-10-12 22:57:32]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define endl '\n'
#define fix(x) cout << fixed << setprecision(x);
#define fastio                             \
    std::ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                         \
    cout.tie(NULL);
#pragma GCC optimize(2)
using namespace std;
const int N = 1e7 + 10, mod = 998244353;
int n, m;
int inv[N];
int fact[N], infact[N];
int A(int n, int m)
{
    return fact[n] * infact[n - m] % mod;
}
void solve()
{
    cin >> n;
    fact[0] = infact[0] = inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    }
    for (int i = 1; i <= n; i++)
    {
        fact[i] = fact[i - 1] * i % mod;
        infact[i] = 1ll * infact[i - 1] * inv[i] % mod;
    }

    int ans = 0;
    for (int i = 1; i <= n / 2 + 1; i++)
    {
        ans += (fact[n - i] * (A(n - i, i - 1)) % mod) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}
signed main()
{
    fastio;
    int t = 1;
    // cin >> t;
    // init();
    while (t--)
    {
        solve();
    }
    return 0;
}

详细

Sorry: IndentationError: unexpected indent (answer.code, line 7)