QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#57897 | #4842. Rectangle Placement | Sorting# | AC ✓ | 3ms | 3700kb | C++ | 1.5kb | 2022-10-23 18:54:37 | 2022-10-23 18:54:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair < int , int > pii ;
#define fi first
#define se second
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MOD = 998244353 ;
ll n , m ;
ll fastpow ( ll x , ll pw ) {
ll ret = 1 ;
while ( pw > 0 ) {
if ( ( pw % 2 ) == 0 ) {
x = ( x * x ) % MOD ;
pw /= 2 ;
}
else {
ret = ( ret * x ) % MOD ;
-- pw ;
}
}
return ret ;
}
ll comb ( ll up , ll down ) {
if ( up < down || down < 0 ) { return 0 ; }
ll ret = 1 ;
for ( ll i = 0 ; i < down ; ++ i ) {
ret = ( ret * ( up - i ) ) % MOD ;
}
for ( ll i = 1 ; i <= down ; ++ i ) {
ret = ( ret * fastpow ( i , MOD - 2 ) ) % MOD ;
}
return ret ;
}
void solve ( ) {
cin >> n >> m ;
ll ans = ( comb ( n , 4 ) * comb ( m , 4 ) ) % MOD ;
ll aux = ( comb ( m , 4 ) * comb ( n , 2 ) ) % MOD ;
aux = ( aux * comb ( n , 2 ) ) % MOD ;
ans = ( ans + aux ) % MOD ;
aux = ( comb ( n , 4 ) * comb ( m , 2 ) ) % MOD ;
aux = ( aux * comb ( m , 2 ) ) % MOD ;
ans = ( ans + aux ) % MOD ;
aux = ( comb ( n , 4 ) * comb ( m , 4 ) ) % MOD ;
aux = ( aux * 2 ) % MOD ;
ans = ( ans + MOD - aux ) % MOD ;
cout << ans << "\n" ;
}
int main ( ) {
ios_base :: sync_with_stdio ( false ) ;
cin.tie ( NULL ) ;
int t = 1 ; // cin >> t ;
while ( t -- ) { solve ( ) ; }
return 0 ;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3596kb
input:
4 5
output:
275
result:
ok 1 number(s): "275"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
723435135 239873451
output:
832099301
result:
ok 1 number(s): "832099301"
Test #3:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
10348683 1000000000
output:
959472414
result:
ok 1 number(s): "959472414"
Test #4:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
1000000000 886687075
output:
994294391
result:
ok 1 number(s): "994294391"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
238133469 977550485
output:
181382226
result:
ok 1 number(s): "181382226"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
895943525 1000000000
output:
574248092
result:
ok 1 number(s): "574248092"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
1000000000 772281920
output:
2306050
result:
ok 1 number(s): "2306050"
Test #8:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
123728314 859786182
output:
722858859
result:
ok 1 number(s): "722858859"
Test #9:
score: 0
Accepted
time: 2ms
memory: 3596kb
input:
76505681 1000000000
output:
94904116
result:
ok 1 number(s): "94904116"
Test #10:
score: 0
Accepted
time: 2ms
memory: 3584kb
input:
1000000000 952844073
output:
632222340
result:
ok 1 number(s): "632222340"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
599257776 36989190
output:
592333335
result:
ok 1 number(s): "592333335"
Test #12:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
257067834 1000000000
output:
520152555
result:
ok 1 number(s): "520152555"
Test #13:
score: 0
Accepted
time: 3ms
memory: 3644kb
input:
1000000000 133406229
output:
769022397
result:
ok 1 number(s): "769022397"
Test #14:
score: 0
Accepted
time: 3ms
memory: 3640kb
input:
484852621 919224885
output:
829749309
result:
ok 1 number(s): "829749309"
Test #15:
score: 0
Accepted
time: 3ms
memory: 3464kb
input:
437629987 1000000000
output:
388969627
result:
ok 1 number(s): "388969627"
Test #16:
score: 0
Accepted
time: 3ms
memory: 3696kb
input:
1000000000 313968382
output:
471013029
result:
ok 1 number(s): "471013029"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
665414774 326352585
output:
424688776
result:
ok 1 number(s): "424688776"
Test #18:
score: 0
Accepted
time: 2ms
memory: 3592kb
input:
1000000000 1000000000
output:
656213933
result:
ok 1 number(s): "656213933"
Test #19:
score: 0
Accepted
time: 3ms
memory: 3700kb
input:
4 4
output:
71
result:
ok 1 number(s): "71"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
4 1000000000
output:
946327704
result:
ok 1 number(s): "946327704"
Test #21:
score: 0
Accepted
time: 2ms
memory: 3596kb
input:
1000000000 4
output:
946327704
result:
ok 1 number(s): "946327704"