QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386733#6736. Alice and BobArnold_6#TL 0ms0kbC++14876b2024-04-11 19:43:022024-04-11 19:43:04

Judging History

This is the latest submission verdict.

  • [2024-04-11 19:43:04]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-04-11 19:43:02]
  • Submitted

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;
    system("pause");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:


result: