QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#47674 | #4556. 你的生命已如风中残烛 | catthomas | 100 ✓ | 11ms | 3808kb | C++ | 871b | 2022-09-10 15:53:50 | 2022-09-10 15:53:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mxn=45;
const int mod=998244353;
int n,m,iv[mxn],i,j,t,k,s,a[mxn];
struct poly
{
int e[mxn];
inline void clr(){memset(e,0,sizeof(e));}
inline void init(int x)
{
int nw=1;
for (int i=0;i<=n;++i,nw=nw*1ll*(x-i+1)%mod*iv[i]%mod)
{
e[i]=nw;
}
}
const poly operator * (const poly x) const
{
poly ret;
ret.clr();
for (int i=0;i<=n;++i)
for (int j=0;j+i<=n;++j)
ret.e[i+j]=(ret.e[i+j]+e[i]*1ll*x.e[j])%mod;
return ret;
}
}b[mxn],ans;
int main()
{
iv[0]=iv[1]=1;
for (i=2;i<mxn;++i) iv[i]=iv[mod%i]*1ll*(mod-mod/i)%mod;
scanf("%d",&n);t=0;
ans.e[0]=1;
for (i=1;i<=n;++i) scanf("%d",&a[i]),b[i].init(a[i]),ans=ans*b[i],t+=a[i]-1;
s=ans.e[n-1];
for (i=1;i<n;++i) s=1ll*s*i%mod;
for (i=1;i<=t;++i) s=1ll*s*i%mod;
printf("%d\n",s);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 0ms
memory: 3752kb
input:
3 3 4 3
output:
453600
result:
ok 1 number(s): "453600"
Test #2:
score: 5
Accepted
time: 2ms
memory: 3672kb
input:
4 1 2 2 5
output:
518400
result:
ok 1 number(s): "518400"
Test #3:
score: 5
Accepted
time: 4ms
memory: 3676kb
input:
8 76668 53399 70796 78419 57556 68926 1915 38643
output:
949898459
result:
ok 1 number(s): "949898459"
Test #4:
score: 5
Accepted
time: 1ms
memory: 3712kb
input:
8 66474 53912 38061 43182 61784 95147 58210 25497
output:
595228635
result:
ok 1 number(s): "595228635"
Test #5:
score: 5
Accepted
time: 4ms
memory: 3808kb
input:
8 98193 97463 63155 19717 46275 13410 75877 75493
output:
77039665
result:
ok 1 number(s): "77039665"
Test #6:
score: 5
Accepted
time: 2ms
memory: 3808kb
input:
8 88099 65208 63288 61281 50503 39730 22505 85448
output:
734593689
result:
ok 1 number(s): "734593689"
Test #7:
score: 5
Accepted
time: 6ms
memory: 3740kb
input:
15 88953 89816 89181 67185 22983 51194 99579 66504 1866 61943 65666 98681 26437 60568 92391
output:
495839407
result:
ok 1 number(s): "495839407"
Test #8:
score: 5
Accepted
time: 5ms
memory: 3740kb
input:
15 479 79765 44320 376 82158 92270 2228 93620 6831 22806 74653 79140 2304 53934 96027
output:
180050111
result:
ok 1 number(s): "180050111"
Test #9:
score: 5
Accepted
time: 2ms
memory: 3672kb
input:
15 12004 69814 9127 89635 64634 33247 27978 43937 34996 50900 60441 26730 1372 24201 32332
output:
442907238
result:
ok 1 number(s): "442907238"
Test #10:
score: 5
Accepted
time: 6ms
memory: 3700kb
input:
30 9465 65528 44324 20323 74038 30853 532 99742 30429 45037 61788 84513 73278 57936 90669 67403 86753 32015 82990 69216 99199 51188 14918 74830 37131 19915 41077 95485 71170 23935
output:
201701591
result:
ok 1 number(s): "201701591"
Test #11:
score: 5
Accepted
time: 9ms
memory: 3780kb
input:
30 20991 55477 76263 76814 33214 71829 70413 50058 58594 96331 47575 32203 39577 28202 94305 54046 10126 97985 50447 4156 69694 75439 24073 74534 45307 26576 52247 59925 16133 97093
output:
722280885
result:
ok 1 number(s): "722280885"
Test #12:
score: 5
Accepted
time: 5ms
memory: 3760kb
input:
15 15087 9880 81660 61274 51644 47011 35666 53433 28306 86973 44311 78046 21037 57611 67488
output:
884473359
result:
ok 1 number(s): "884473359"
Test #13:
score: 5
Accepted
time: 4ms
memory: 3728kb
input:
30 14768 64470 96472 95312 81873 67839 59299 85410 36170 66860 31286 34221 41954 59651 65415 51788 17057 2767 72705 40337 63741 26430 39686 36819 68540 67239 40647 49301 3104 2520
output:
107610869
result:
ok 1 number(s): "107610869"
Test #14:
score: 5
Accepted
time: 8ms
memory: 3704kb
input:
30 15245 76824 93084 43530 72897 23572 64270 75889 40810 21098 92761 73297 69662 15210 58934 49962 21610 40994 64913 31550 32971 60902 24393 11055 19414 60659 94266 47631 96433 41597
output:
690905035
result:
ok 1 number(s): "690905035"
Test #15:
score: 5
Accepted
time: 10ms
memory: 3680kb
input:
40 8611 64120 18331 37619 1558 19389 23458 85917 34582 69329 71506 52661 64261 79485 24463 71055 91279 32361 65807 9990 16707 58942 68602 26458 35383 86675 33840 22025 18976 25049 65190 92830 75996 56038 10741 38048 94346 21241 81095 42594
output:
657182250
result:
ok 1 number(s): "657182250"
Test #16:
score: 5
Accepted
time: 11ms
memory: 3744kb
input:
40 97085 74070 53624 81128 42383 78313 97709 35701 6417 8466 62518 72303 65194 86119 20826 28544 67906 99259 54318 51849 46212 34791 59447 26654 94439 47247 22669 80785 6782 61458 19527 8271 69923 31258 73669 75318 95475 56110 48960 82049
output:
330077666
result:
ok 1 number(s): "330077666"
Test #17:
score: 5
Accepted
time: 6ms
memory: 3652kb
input:
40 95334 47767 36263 40312 86008 31844 39297 30508 46362 2439 53605 24682 82254 9918 45396 10196 54678 35276 74629 26497 45520 11872 6808 66135 3413 26648 99060 60661 86918 19950 25089 59502 48414 89418 78723 64352 97194 9522 54778 5069
output:
473192665
result:
ok 1 number(s): "473192665"
Test #18:
score: 5
Accepted
time: 10ms
memory: 3740kb
input:
40 96289 49175 39056 90248 58387 10641 16371 44332 32641 10915 43887 89302 14471 65268 78834 6544 73353 90998 24580 85723 51212 4117 8991 37707 49293 59788 6197 1354 15912 51604 98218 97840 36355 82607 12079 41266 73585 18870 69363 6738
output:
906838232
result:
ok 1 number(s): "906838232"
Test #19:
score: 5
Accepted
time: 10ms
memory: 3716kb
input:
40 18863 40119 62289 87780 62615 36861 72666 21619 61031 36066 9955 68607 52029 29111 25355 37624 15544 95776 22582 10791 22972 50716 86726 83810 70539 56589 65451 31904 70173 16508 62347 9339 95061 68342 36926 49487 39149 94510 8024 37894
output:
74083642
result:
ok 1 number(s): "74083642"
Test #20:
score: 5
Accepted
time: 11ms
memory: 3720kb
input:
40 30388 30069 94328 21071 21891 77937 65648 48735 56428 64061 95743 92997 51096 99278 28992 24167 6149 52078 90039 45731 93466 30835 72782 60314 1916 96017 76621 73144 38235 89567 8010 17098 68365 93122 18130 21886 38020 59642 72926 21638
output:
670711472
result:
ok 1 number(s): "670711472"
Extra Test:
score: 0
Extra Test Passed