QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386734#6736. Alice and BobArnold_6#TL 0ms0kbC++14854b2024-04-11 19:44:072024-04-11 19:44:07

Judging History

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

  • [2024-04-11 19:44:07]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-11 19:44:07]
  • 提交

answer

# include <bits/stdc++.h>

using namespace std;
const int N = 1e7 + 10, mod = 998244353;
typedef long long LL;
int n;
LL fact[N], infact[N];

int qp(int a, int k)
{
    int res = 1;
    while(k)
    {
        if(k & 1) res = (LL)res * a % mod;
        a = (LL) a * a % mod;
        k >>= 1;
    }
    return res;
}

void init()
{
    fact[0] = infact[0] = 1;
    for(int i = 1; i < N; i ++)
    {
        fact[i] = (LL)fact[i - 1] * i % mod;
        infact[i] = qp(fact[i], mod - 2);
    }

}

int A(int y, int x)
{
    return (LL)fact[x] * infact[x - y] % mod;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: