QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620348#8149. Station of FateHSTKwowWA 1ms4484kbC++14748b2024-10-07 17:39:302024-10-07 17:39:36

Judging History

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

  • [2024-10-07 17:39:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4484kb
  • [2024-10-07 17:39:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
const int mod=998244353;
ll an[100005];

void ope() {
    an[0]=1;
    for(int i=1; i<=100000; i++)
        an[i]=an[i-1]*i%mod;
}


ll cnm(int n, int k) {
    if (k > n) return 0;
    if (k == 0 || k == n) return 1;
    if (k > n - k) k = n - k; // C(n, k) == C(n, n-k)
    ll result = 1;
    for (int i = 0; i < k; ++i) {
        result = (result * (n - i) / (i + 1)) % mod ;
    }
    return result;
}

                            
signed main() {
    ios::sync_with_stdio(false),cin.tie(nullptr);
    ope();
    int t; cin>>t;
    while(t--) {
        ll n,m; cin>>n>>m;
        cout<<cnm(n-1,m-1)*an[n]%mod<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4476kb

input:

2
3 2
6 3

output:

12
7200

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 4360kb

input:

4
6 5
2 2
7 5
1 1

output:

3600
2
75600
1

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 4432kb

input:

8
10 3
3 3
4 4
9 7
8 2
6 4
7 2
2 2

output:

130636800
6
24
10160640
282240
7200
30240
2

result:

ok 8 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 4436kb

input:

2
3 3
1 1

output:

6
1

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 4480kb

input:

6
3 1
9 2
6 4
5 5
8 1
8 4

output:

6
2903040
7200
120
40320
1411200

result:

ok 6 lines

Test #6:

score: 0
Accepted
time: 1ms
memory: 4440kb

input:

4
7 1
6 6
3 3
3 2

output:

5040
720
6
12

result:

ok 4 lines

Test #7:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

8
2 1
10 6
7 6
1 1
7 2
1 1
2 1
7 1

output:

2
457228800
30240
1
30240
1
2
5040

result:

ok 8 lines

Test #8:

score: 0
Accepted
time: 1ms
memory: 4360kb

input:

2
6 5
8 4

output:

3600
1411200

result:

ok 2 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 4352kb

input:

6
1 1
5 1
1 1
7 1
1 1
4 1

output:

1
120
1
5040
1
24

result:

ok 6 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

4
3 3
7 2
6 5
5 5

output:

6
30240
3600
120

result:

ok 4 lines

Test #11:

score: 0
Accepted
time: 1ms
memory: 4400kb

input:

8
7 7
3 2
10 5
7 3
2 2
2 1
8 7
9 2

output:

5040
12
457228800
75600
2
2
282240
2903040

result:

ok 8 lines

Test #12:

score: 0
Accepted
time: 1ms
memory: 4352kb

input:

3
5 5
7 2
7 5

output:

120
30240
75600

result:

ok 3 lines

Test #13:

score: 0
Accepted
time: 1ms
memory: 4472kb

input:

7
6 6
10 9
6 2
3 2
6 1
5 1
8 5

output:

720
32659200
3600
12
720
120
1411200

result:

ok 7 lines

Test #14:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

5
10 8
2 1
8 3
1 1
9 5

output:

130636800
2
846720
1
25401600

result:

ok 5 lines

Test #15:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

5
4 2
10 7
5 2
5 1
7 3

output:

72
304819200
480
120
75600

result:

ok 5 lines

Test #16:

score: 0
Accepted
time: 1ms
memory: 4356kb

input:

3
5 2
3 2
10 10

output:

480
12
3628800

result:

ok 3 lines

Test #17:

score: 0
Accepted
time: 1ms
memory: 4420kb

input:

7
1 1
1 1
7 3
5 2
5 3
4 3
3 1

output:

1
1
75600
480
720
72
6

result:

ok 7 lines

Test #18:

score: 0
Accepted
time: 1ms
memory: 4364kb

input:

5
1 1
2 1
8 8
3 3
4 1

output:

1
2
40320
6
24

result:

ok 5 lines

Test #19:

score: 0
Accepted
time: 1ms
memory: 4476kb

input:

5
6 4
10 3
2 2
1 1
6 3

output:

7200
130636800
2
1
7200

result:

ok 5 lines

Test #20:

score: -100
Wrong Answer
time: 1ms
memory: 4484kb

input:

8
52 4
68 41
82 17
73 15
44 25
84 34
81 23
59 57

output:

39982437
226623348
698674033
85023521
77095061
614407166
391405437
789353276

result:

wrong answer 2nd lines differ - expected: '271239302', found: '226623348'