ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213038 | #3823. 艾特扣德 | shiruiheng | 20 | 886ms | 12404kb | C++11 | 1.2kb | 2024-11-03 12:58:31 | 2024-11-03 13:02:55 |
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using LL = __int128
#define pi pair<ll, ll>
#define fi first
#define se second
//#define fi(x) (x->first)
//#define se(x) (x->second)
#define N 1111111
#define mod 998244353ll
ll n, a[N], m, t, fac[N] = {1};
ll bigmul(ll a, ll b, ll m) {
unsigned long long c =
(unsigned long long)a * b -
(unsigned long long)((long double)a / m * b + 0.5L) * m;
return (c + m) % m;
}
ll qpow(ll x, ll y){
ll ans = 1, res = x % mod ;
while(y){
if(y & 1)
ans = bigmul(ans, res, mod);
res = bigmul(res, res, mod);
y >>= 1 ;
}
return ans ;
}
ll inv(ll x){
return qpow(x, mod - 2);
}
ll c(ll x, ll y){
return fac[x] * inv(fac[y]) % mod * inv(fac[x - y]) % mod;
}
int main(){
for(int i = 1 ; i < N ; i++)
fac[i] = fac[i - 1] * i % mod;
scanf("%lld", &t);
while(t--){
scanf("%lld%lld", &n, &m);
for(int i = 1 ; i <= m ; i++){
scanf("%lld", &a[i]);
}
if(*min_element(a + 1, a + 1 + m) == 0){
printf("%lld\n", fac[n - m] * c(n, m) % mod);
continue;
}
if(m == 1){
printf("%lld\n", fac[n]);
}
}
return 0;
}
/*
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
*/
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 9876kb
input:
100 4 4 3 0 1 2 3 1 0 5 2 1 3 5 3 1 4 2 5 3 0 4 2 3 1 0 5 1 3 3 3 1 2 0 3 1 0 4 3 0 2 3 4 2 0 2 5 1 ...
output:
1 6 20 6 120 1 6 4 12 120 1 24 4 4 12 1 1 24 4 1 60 1 2 2 1 120 1 120 20 12 12 3 120 120 60 1 24 60 ...
result:
wrong answer 3rd lines differ - expected: '60', found: '20'
Test #2:
score: 0
Wrong Answer
time: 498ms
memory: 9880kb
input:
1000000 420929 1 239064 93187 1 85123 171379 1 110159 658643 1 0 303046 1 95912 800861 1 781035 9893...
output:
770136380 314609747 93672371 191686493 918943996 667267785 24549137 845801455 33476619 305016352 906...
result:
wrong answer 1st lines differ - expected: '598226497', found: '770136380'
Test #3:
score: 20
Accepted
time: 154ms
memory: 12404kb
input:
38765 832568 1 0 992725 6 548209 466528 628957 748938 0 578853 943934 15 863133 363066 513728 634152...
output:
485766967 626192578 109003053 452562070 536252017 398732909 215760199 971680463 57876225 982883068 7...
result:
ok 38765 lines
Test #4:
score: 0
Wrong Answer
time: 115ms
memory: 12356kb
input:
38573 988634 10 800634 876452 811249 495916 842656 695203 0 914758 757887 237251 948749 6 282623 267...
output:
184333188 888302414 617843139 541399598 537526380 319719384 409299415 430713376 119672838 478303098 ...
result:
wrong answer 2nd lines differ - expected: '275156102', found: '888302414'
Test #5:
score: 0
Wrong Answer
time: 115ms
memory: 12044kb
input:
38561 996249 6 150367 424546 851150 536915 420708 392670 956743 7 858128 296060 304111 814957 936254...
output:
117799344 257319117 286532419 456042196 302360174 829239921 709572673 829496664 866722965 177368508 ...
result:
wrong answer 1st lines differ - expected: '204801326', found: '117799344'