QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386751#6736. Alice and BobArnold_6#RE 0ms0kbC++14998b2024-04-11 19:50:142024-04-11 19:50:15

Judging History

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

  • [2024-04-11 19:50:15]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-11 19:50:14]
  • 提交

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], inv[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;
    inv[1] = 1;
    for(int i = 2; i < N; i ++) inv[i] = (LL)(mod - mod / i) * inv[mod % i] % mod;
    for(int i = 1; i < N; i ++)
    {
        fact[i] = (LL)fact[i - 1] * i % mod; 
        infact[i] = (LL)infact[i - 1] * inv[i] % mod;
    }

}

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
Dangerous Syscalls

input:

1

output:

1

result: