QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367174#6736. Alice and BobwhopxxTL 270ms81860kbC++20970b2024-03-25 19:53:392024-03-25 19:53:40

Judging History

This is the latest submission verdict.

  • [2024-03-25 19:53:40]
  • Judged
  • Verdict: TL
  • Time: 270ms
  • Memory: 81860kb
  • [2024-03-25 19:53:39]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 1e7 + 10;
int a[N];

void init(){
    a[0] = 1;
    for(int i = 1; i <= 1e7 + 2; i++){
        a[i] = a[i - 1] * i % mod;
    }
}

int ksm(int a,int b){
    int res = 1;
    while(b){
        if(b & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}

int A(int n,int m){

    if(n - m < 0)return 0;
    return a[n] * ksm(a[n - m], mod - 2) % mod;
}

void solve(){
    init();
    int n = 10;
    cin >> n;
    int ans = 0;
    for(int x = 1; x <= n; x++){
        ans += A(n - x,x - 1) * A(n - x,n - x) % mod;
        ans %= mod;
    }
    cout << ans % mod << endl;
    
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _(1);
    // cin >> _;
    while(_ --){
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 51ms
memory: 81860kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 11ms
memory: 81784kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 46ms
memory: 81780kb

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

score: 0
Accepted
time: 39ms
memory: 81780kb

input:

100

output:

188898954

result:

ok 1 number(s): "188898954"

Test #5:

score: 0
Accepted
time: 27ms
memory: 81780kb

input:

4

output:

10

result:

ok 1 number(s): "10"

Test #6:

score: 0
Accepted
time: 39ms
memory: 81804kb

input:

8

output:

12336

result:

ok 1 number(s): "12336"

Test #7:

score: 0
Accepted
time: 35ms
memory: 81704kb

input:

16

output:

373118483

result:

ok 1 number(s): "373118483"

Test #8:

score: 0
Accepted
time: 42ms
memory: 81776kb

input:

32

output:

314585464

result:

ok 1 number(s): "314585464"

Test #9:

score: 0
Accepted
time: 46ms
memory: 81768kb

input:

64

output:

627827331

result:

ok 1 number(s): "627827331"

Test #10:

score: 0
Accepted
time: 38ms
memory: 81772kb

input:

128

output:

828497685

result:

ok 1 number(s): "828497685"

Test #11:

score: 0
Accepted
time: 33ms
memory: 81732kb

input:

256

output:

65697890

result:

ok 1 number(s): "65697890"

Test #12:

score: 0
Accepted
time: 39ms
memory: 81788kb

input:

512

output:

854187619

result:

ok 1 number(s): "854187619"

Test #13:

score: 0
Accepted
time: 39ms
memory: 81724kb

input:

1024

output:

513823539

result:

ok 1 number(s): "513823539"

Test #14:

score: 0
Accepted
time: 270ms
memory: 81780kb

input:

1361956

output:

617368199

result:

ok 1 number(s): "617368199"

Test #15:

score: -100
Time Limit Exceeded

input:

7579013

output:


result: