QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#620370#8149. Station of Fatecy325WA 1ms3724kbC++20993b2024-10-07 17:47:262024-10-07 17:47:27

Judging History

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

  • [2024-10-07 17:47:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3724kb
  • [2024-10-07 17:47:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=998244353;
ll an[100005];
ll mul(ll a,ll b,ll mod){
    a=a%mod;
    b=b%mod;
    ll res=0;
    while(b>0){
        if(b&1)res=(res+a)%mod;
        a=(a+a)%mod;
        b>>=1;
    }
    return res;
}
ll A(ll a){
    ll ans=1;
    for(ll i=1;i<=a;i++) {
        ans=mul(ans,i,mod);
    }
    return ans%mod;
}
ll C(ll cn,ll cm){
    ll ans_cm=A(cm);
    ll ans_cn=1;
    for(ll i=cn;cm>0;cm--,cn--){
        ans_cn=mul(ans_cn,cn,mod);
    }
    return ans_cn/ans_cm;
}

signed main() {
    ios::sync_with_stdio(false),cin.tie(nullptr);
    ll t;
    cin>>t;

    while(t--){
        ll n, m;
        cin >> n >> m;
//    ll a=0x7877665544332211;
//    ll b=0x7988776655443322;
//    ll mod=0x998776655443322;
//    cout<<mul(a,b,mod);
//    cout<<(C(n-1,m-1)%mod)<<endl;
//        cout <<C(n-1,m-1)<< endl;
        cout << mul(C(n-1,m-1),A(n),mod) << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

2
3 2
6 3

output:

12
7200

result:

ok 2 lines

Test #2:

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

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: 0ms
memory: 3652kb

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: 3708kb

input:

2
3 3
1 1

output:

6
1

result:

ok 2 lines

Test #5:

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

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: 0ms
memory: 3572kb

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: 0ms
memory: 3652kb

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: 0ms
memory: 3588kb

input:

2
6 5
8 4

output:

3600
1411200

result:

ok 2 lines

Test #9:

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

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: 0ms
memory: 3592kb

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: 0ms
memory: 3660kb

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: 0ms
memory: 3648kb

input:

3
5 5
7 2
7 5

output:

120
30240
75600

result:

ok 3 lines

Test #13:

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

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: 0ms
memory: 3716kb

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: 0ms
memory: 3656kb

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: 3712kb

input:

3
5 2
3 2
10 10

output:

480
12
3628800

result:

ok 3 lines

Test #17:

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

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: 0ms
memory: 3712kb

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: 0ms
memory: 3656kb

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: 0ms
memory: 3600kb

input:

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

output:

39982437
0
0
0
0
0
0
258946120

result:

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