QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#822758#9906. 乘积的期望zjy00010 1508ms12284kbC++171.9kb2024-12-20 16:17:382024-12-20 16:17:38

Judging History

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

  • [2024-12-20 16:17:38]
  • 评测
  • 测评结果:0
  • 用时:1508ms
  • 内存:12284kb
  • [2024-12-20 16:17:38]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=55,M=16,Mod=998244353;
int n,m,c,sb,ans=1;
int b[N],frc[N],ivf[N],pw[N][N],pwb[N][N],F[N],f[N][N][1<<M];
inline int qpow(int x,int y,int z=1){
	for(;y;(y>>=1)&&(x=(LL)x*x%Mod))if(y&1)z=(LL)z*x%Mod;return z;
}
inline int Langrange(int* F,int n,int x){
    if(x<=n)return F[x];
    int z=0;
    for(int i=0;i<=n+1;++i){
        int v=1,w=1;
        for(int j=0;j<=n+1;++j)v=(LL)v*(i-j)%Mod,w=(LL)w*(x-j)%Mod;
        v=qpow(v,Mod-2,F[i]);
        z=(z+(LL)w*v)%Mod;
    }
    return z<0?z+Mod:z;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>m>>c;
    for(int i=0;i<=n-m;++i)cin>>b[i],sb+=b[i];
    while(n<m+m)ans=1ll*ans*c%Mod,--n,--m;
    sb=qpow(sb,Mod-2);
    for(int i=0;i<=n-m;++i)b[i]=(LL)b[i]*sb%Mod;
    for(int i=0;i<=n-m;++i){
        pwb[i][0]=1;
        for(int j=1;j<=n+1;++j)pwb[i][j]=(LL)pwb[i][j-1]*b[i]%Mod;
    }
    for(int i=0;i<=n;++i){
        pw[i][0]=1;
        for(int j=1;j<=n+1;++j)pw[i][j]=(LL)pw[i][j-1]*i%Mod;
    }
    frc[0]=1,ivf[0]=1;
    for(int i=1;i<=n+1;++i)
        frc[i]=(LL)frc[i-1]*i%Mod,ivf[i]=qpow(frc[i],Mod-2);
    // if(m+m+m<=n){
    if(m<=16){
        f[0][0][1]=1;
        for(int i=0;i<=n-m;++i)
            for(int S=1;S<(1<<m);S+=2)
                for(int U=(1<<m)-1-(S>>1),T=U;;T=(T-1)&U){
                    for(int j=0;j<=n+1;++j)
                        for(int k=0;j+k<=n+1;++k)if(f[i][j][S])
                            f[i+1][j+k][S>>1|T]=(f[i+1][j+k][S>>1|T]+(LL)f[i][j][S]*pw[k][__builtin_popcount(T)]%Mod*ivf[k]%Mod*pwb[i][k])%Mod;
                    if(!T)break;
                }
        for(int i=0;i<=n+1;++i)F[i]=(LL)f[n-m+1][i][(1<<m)-1]*frc[i]%Mod;
        cout<<(LL)Langrange(F,n+1,c)*ans%Mod<<'\n';
    }
    else{

    }
    return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1508ms
memory: 11924kb

input:

50 8 538603133
67980 83398 26783 9496 18845 44534 25751 12189 79555 49066 87559 96963 11358 39078 24880 28212 34282 24882 137 65957 82361 13906 96900 98969 84165 18398 39061 3819 69062 26508 50351 14635 53121 29490 50901 32530 6748 40834 98869 30306 21857 78350 4599

output:

0

result:

wrong answer 1st words differ - expected: '780535604', found: '0'

Subtask #2:

score: 0
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

input:

50 16 741556017
69810 78288 21013 9835 661 55545 30670 5295 93027 2280 84775 68841 409 27907 27934 30629 4727 72420 32399 56614 387 66084 24179 58626 65756 40652 2761 38442 35627 60928 38003 70482 82058 80740 76968

output:


result:


Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 15
Accepted
time: 2ms
memory: 4856kb

input:

20 2 20
15733 41504 1298 31206 29251 80612 23096 62011 53587 93432 61688 29933 49923 56050 48077 18165 94224 89994 73376

output:

462941922

result:

ok "462941922"

Test #6:

score: 15
Accepted
time: 0ms
memory: 4996kb

input:

20 3 20
57522 48009 37618 39300 19577 44005 65454 97035 85345 80443 97133 52062 91020 52423 83416 21116 74840 76619

output:

540559668

result:

ok "540559668"

Test #7:

score: 15
Accepted
time: 3ms
memory: 4884kb

input:

20 4 20
60925 70573 53982 31710 66093 18975 7260 83233 67515 95597 44015 58869 34028 36548 45651 23271 52701

output:

611973859

result:

ok "611973859"

Test #8:

score: 15
Accepted
time: 0ms
memory: 4848kb

input:

20 5 20
82390 2317 82179 18938 9953 34563 82381 70783 97738 81517 17602 56993 58751 59673 9558 73494

output:

488417654

result:

ok "488417654"

Test #9:

score: 15
Accepted
time: 11ms
memory: 5044kb

input:

20 6 20
4771 68929 33616 57489 4669 17494 94028 43155 50480 55531 98839 87302 87698 21218 63988

output:

655440595

result:

ok "655440595"

Test #10:

score: 15
Accepted
time: 30ms
memory: 4776kb

input:

20 7 20
68307 10269 840 3121 93665 53351 26597 97291 62697 11200 87435 54633 26415 94315

output:

538177939

result:

ok "538177939"

Test #11:

score: 15
Accepted
time: 80ms
memory: 4708kb

input:

20 8 20
94622 30267 99868 82290 60454 482 96118 32322 77392 47281 68220 43584 79613

output:

983197463

result:

ok "983197463"

Test #12:

score: 15
Accepted
time: 216ms
memory: 4612kb

input:

20 9 20
40104 90548 19465 44878 21994 5498 52682 63165 12176 4666 20666 89555

output:

984574821

result:

ok "984574821"

Test #13:

score: 15
Accepted
time: 597ms
memory: 5692kb

input:

20 10 20
67417 20117 81885 6396 70004 86426 73034 32420 34993 47876 97728

output:

336081501

result:

ok "336081501"

Test #14:

score: 0
Wrong Answer
time: 146ms
memory: 4544kb

input:

20 11 20
99807 80522 52177 65878 99955 73779 96792 36724 59702 36109

output:

0

result:

wrong answer 1st words differ - expected: '676922342', found: '0'

Subtask #4:

score: 0
Time Limit Exceeded

Test #16:

score: 15
Accepted
time: 0ms
memory: 6716kb

input:

30 2 30
63840 50413 47135 89472 59483 28187 26327 20630 9120 5935 35689 11933 65347 7807 67870 97007 98326 57595 38213 70182 28242 45443 98275 17795 64068 90290 77827 40552 52025

output:

325631710

result:

ok "325631710"

Test #17:

score: 15
Accepted
time: 0ms
memory: 6584kb

input:

30 3 30
58754 9093 33080 66153 24781 95196 70341 93542 64458 69630 3648 43011 78044 97039 73733 8851 1896 29496 98337 21621 94366 11212 26578 29439 74055 78934 25756 1851

output:

851829651

result:

ok "851829651"

Test #18:

score: 15
Accepted
time: 3ms
memory: 6692kb

input:

30 4 30
70665 9951 85696 25954 89838 90092 83036 79852 70557 78760 60484 87643 10448 6715 68462 4493 82690 8559 30903 5905 39538 81729 8336 75504 89887 68791 66413

output:

172769472

result:

ok "172769472"

Test #19:

score: 15
Accepted
time: 15ms
memory: 6592kb

input:

30 5 30
4616 33385 72106 14845 67092 3951 96876 7368 54847 48413 60577 59351 58653 70687 42529 64602 820 22253 86012 75249 25748 93849 91461 24425 19817 22975

output:

745999087

result:

ok "745999087"

Test #20:

score: 15
Accepted
time: 39ms
memory: 6596kb

input:

30 6 30
68519 56186 7862 25791 15648 16165 43082 86076 92196 77604 7951 96158 62855 81679 56293 89222 84771 226 43433 5233 32700 17535 86592 18798 74119

output:

322276513

result:

ok "322276513"

Test #21:

score: 15
Accepted
time: 99ms
memory: 6708kb

input:

30 7 30
11979 43527 49710 83806 59784 10553 68014 56617 56964 20855 89934 83282 47947 91684 29142 14582 22216 47716 42934 88501 12941 81062 98625 86477

output:

479411090

result:

ok "479411090"

Test #22:

score: 15
Accepted
time: 296ms
memory: 6268kb

input:

30 8 30
50530 478 23599 15778 21860 54253 34595 9777 63783 10943 26328 8586 90283 7759 34046 90014 58492 23149 15587 50844 74581 49737 26174

output:

988323551

result:

ok "988323551"

Test #23:

score: 15
Accepted
time: 874ms
memory: 6284kb

input:

30 9 30
52373 94342 29939 70926 23969 36137 48228 13762 11057 85576 10055 13114 77103 42530 23705 83562 45258 46500 31125 32543 7826 38012

output:

198006227

result:

ok "198006227"

Test #24:

score: 0
Time Limit Exceeded

input:

30 10 30
66855 12442 31206 69706 41102 13002 71643 15297 96987 9399 43850 84667 70263 97248 70337 70772 96208 25811 31946 63360 13780

output:


result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #35:

score: 15
Accepted
time: 2ms
memory: 8644kb

input:

40 2 40
35138 42435 44437 707 7353 69441 86322 53577 70023 6596 29411 46831 24261 46551 61944 37823 76356 70071 2125 29889 42261 75504 48476 73665 40836 83539 15019 32 70786 23007 75297 39802 45176 74888 64949 65975 20791 74909 3174

output:

272092213

result:

ok "272092213"

Test #36:

score: 15
Accepted
time: 4ms
memory: 9248kb

input:

40 3 40
71100 68198 31780 89574 17629 66878 44226 75602 9923 3197 13761 17979 95562 40271 15950 21383 7904 75208 65826 12943 66864 8901 16830 50349 47157 3255 19410 73815 75217 35628 11839 39663 33376 98009 28434 25197 96530 11916

output:

756937948

result:

ok "756937948"

Test #37:

score: 15
Accepted
time: 11ms
memory: 9048kb

input:

40 4 40
18267 87400 24737 39364 49406 44146 68860 73686 66473 25089 14386 4341 51873 4470 52773 54215 86457 3144 8169 84880 63200 7604 48305 83228 70617 78343 44987 89465 68212 2688 21433 25103 97185 5745 70037 67867 87650

output:

932235563

result:

ok "932235563"

Test #38:

score: 15
Accepted
time: 34ms
memory: 9100kb

input:

40 5 40
79213 93638 1075 40058 39851 18424 41024 12561 85281 60808 73986 94177 13354 9098 58534 7504 40433 89494 42514 60354 71445 61038 35277 70563 24545 51024 39955 6610 58894 98867 44346 71217 34653 31472 97507 24244

output:

265604217

result:

ok "265604217"

Test #39:

score: 15
Accepted
time: 89ms
memory: 8928kb

input:

40 6 40
13136 45215 78397 27958 18696 27713 26785 76785 55059 63834 94616 73045 71879 98953 86697 19717 26214 4420 98410 14040 91055 51076 54283 288 2201 53187 60510 40903 48472 26339 33860 64399 14624 5316 89041

output:

459926865

result:

ok "459926865"

Test #40:

score: 15
Accepted
time: 255ms
memory: 8948kb

input:

40 7 40
13291 15112 5901 47419 59971 56553 70301 54132 78871 17227 23376 63262 47081 3603 53707 68249 60392 74222 35948 93693 39147 96268 83133 73155 17148 40820 92704 73284 97318 17751 28876 83166 32064 48116

output:

961301214

result:

ok "961301214"

Test #41:

score: 15
Accepted
time: 749ms
memory: 8836kb

input:

40 8 40
19184 69028 28504 19515 61680 8242 31347 75928 30064 25580 43644 12978 90742 86638 85532 86894 58945 9010 96354 82384 59210 76066 22164 49992 97906 31831 21312 71675 44627 60340 93515 92716 43354

output:

196212497

result:

ok "196212497"

Test #42:

score: 0
Time Limit Exceeded

input:

40 9 40
10830 3889 7327 22854 66931 50142 22369 58379 19041 38563 9042 91755 82900 81485 75186 72224 73801 74958 73853 32208 44483 55391 65509 99350 80387 71719 53611 94566 64027 29375 47535 23979

output:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #60:

score: 15
Accepted
time: 0ms
memory: 11628kb

input:

50 2 50
53029 77661 89821 96796 28335 72369 90651 95802 13374 29886 81635 88365 51184 98387 7102 32265 60561 23222 99406 30927 59740 76150 85630 96176 10160 70769 19803 42511 26180 40659 21813 44505 37884 93565 75651 24071 59735 21876 92814 23825 99659 86324 3121 57736 47497 42211 19049 28386 62614

output:

966860170

result:

ok "966860170"

Test #61:

score: 15
Accepted
time: 8ms
memory: 12048kb

input:

50 3 50
96445 17531 4985 23485 13120 58689 66414 77376 99105 34985 52873 99206 20358 54743 56826 23382 61605 44307 43828 79980 47627 16387 35 46167 59598 49047 20753 69122 67406 89098 98604 73441 7364 73297 34961 17242 47050 27238 20463 42460 564 62305 30757 63016 93486 14093 4321 85391

output:

275707768

result:

ok "275707768"

Test #62:

score: 15
Accepted
time: 15ms
memory: 12176kb

input:

50 4 50
74938 23059 67849 99019 40296 34071 83582 37652 30622 46626 59266 20048 46849 2256 15255 42610 92619 40455 16548 78028 74707 42108 47598 21417 61795 56917 42288 42360 73614 49594 32133 37558 16840 14096 59556 31733 88554 13726 27151 47197 66555 52085 37486 85423 31240 41455 9476

output:

535543625

result:

ok "535543625"

Test #63:

score: 15
Accepted
time: 54ms
memory: 12284kb

input:

50 5 50
7060 46842 14170 61800 73324 87736 90002 900 74923 57156 63841 67704 26366 59428 86766 41384 23691 62248 89959 15336 84515 79004 96333 41741 97521 73536 25922 21015 82905 56513 46291 93889 64519 92731 54654 44343 237 13858 94701 90536 63762 79544 29126 53519 38244 65619

output:

870962285

result:

ok "870962285"

Test #64:

score: 15
Accepted
time: 177ms
memory: 12176kb

input:

50 6 50
64959 28210 37728 17098 71426 42982 92453 40335 28714 584 35795 7730 29650 54353 8263 65605 48895 54358 57899 84757 28766 94548 1618 85984 71002 89515 13811 95270 99883 24796 85059 59037 76746 42209 4568 8983 41819 61014 44398 89465 94647 49655 15088 24818 91141

output:

643042630

result:

ok "643042630"

Test #65:

score: 15
Accepted
time: 516ms
memory: 12148kb

input:

50 7 50
69117 22907 49998 22118 52072 67379 11081 61522 32796 19666 75556 81101 95643 42449 79385 40460 85775 74898 49734 90978 26116 24073 77800 97206 80342 79176 26719 47801 32725 682 72332 30095 23469 16354 95413 58769 41611 15522 33144 38557 50622 72506 4933 63622

output:

712790994

result:

ok "712790994"

Test #66:

score: 15
Accepted
time: 1506ms
memory: 12028kb

input:

50 8 50
49569 78329 63498 65496 40759 49529 90061 92912 81259 12538 19900 22760 4347 61746 77129 70127 78851 69849 65399 94519 76410 23542 37028 98351 64260 99163 85113 6231 22918 1704 7987 29955 80582 58034 19354 33357 54959 74446 16833 94301 98799 7241 37787

output:

758769960

result:

ok "758769960"

Test #67:

score: 0
Time Limit Exceeded

input:

50 9 50
34112 34920 69853 89379 46478 94340 79906 86572 93276 89070 81279 52826 14491 9271 41289 72513 31923 63351 78035 69850 49241 28625 3590 36740 92720 95725 82140 98552 16923 31290 73899 3838 36298 77916 68761 50821 26984 169 97630 64510 43674 63803

output:


result:


Subtask #7:

score: 0
Wrong Answer

Test #91:

score: 0
Wrong Answer
time: 0ms
memory: 11340kb

input:

50 2 803148095
69632 6145 90266 98714 33652 25290 13413 24460 73968 20427 63478 45461 84799 58528 32781 71127 95223 49585 47134 68284 92786 64910 46840 90501 28361 70029 52269 71032 64637 4223 74513 31660 86876 17066 76967 7309 69967 29448 90148 51876 85305 47798 57822 85122 5026 11764 59061 42974 3...

output:

0

result:

wrong answer 1st words differ - expected: '76793352', found: '0'