QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#468642 | #2506. 数列 | little_sun | 100 ✓ | 63ms | 15596kb | C++14 | 1.6kb | 2024-07-08 21:56:56 | 2024-07-08 21:56:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int read()
{
int x=0,f=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
return x*f;
}
const int mod=998244353;
const int maxN=31;
const int maxM=105;
int fact[maxN],inv_fact[maxN];
int fpow(int x,int y)
{
int res=1;
while(y)
{
if(y&1) res=(long long)res*x%mod;
x=(long long)x*x%mod;
y>>=1;
}
return res;
}
int inv(int x)
{
return fpow(x,mod-2);
}
int v[maxM];
int pow_v[maxM][maxN];
int f[maxM][maxN][maxN][maxN];
void inc(int &x,int y)
{
x+=y;
if(x>mod) x-=mod;
}
int spopcount(int x)
{
int res=0;
while(x)
{
res++;
x-=x&(-x);
}
return res;
}
int main()
{
int n=read(),m=read(),K=read();
fact[0]=1;
for(int i=1;i<=n;i++) fact[i]=(long long)fact[i-1]*i%mod;
inv_fact[n]=inv(fact[n]);
for(int i=n-1;i>=0;i--) inv_fact[i]=(long long)inv_fact[i+1]*(i+1)%mod;
for(int i=0;i<=m;i++) v[i]=read();
for(int i=0;i<=m;i++)
{
pow_v[i][0]=1;
for(int j=1;j<=n;j++) pow_v[i][j]=(long long)pow_v[i][j-1]*v[i]%mod;
}
for(int i=0;i<=n;i++) f[0][i][i/2][i&1]=(long long)inv_fact[i]*pow_v[0][i]%mod;
for(int i=1;i<=m;i++) //f[i][j][k][l] i j个 进位k l个1
for(int j=0;j<=n;j++)
for(int k=0;k<=n/2;k++)
for(int l=0;l<=min(i,K);l++)
for(int x=0;j+x<=n;x++)
inc(f[i][j+x][(x+k)/2][l+((x+k)&1)],(long long)inv_fact[x]*pow_v[i][x]%mod*f[i-1][j][k][l]%mod);
int ans=0;
for(int i=0;i<=n/2;i++)
{
int tmp=spopcount(i);
for(int j=0;j+tmp<=K;j++) inc(ans,f[m][n][i][j]);
}
ans=(long long)ans*fact[n]%mod;
printf("%d\n",ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 5
Accepted
time: 1ms
memory: 4144kb
input:
8 9 1 499488183 118995914 332316574 399234563 246850128 338768262 489466833 673193710 723933572 12759125
output:
789420212
result:
ok single line: '789420212'
Test #2:
score: 5
Accepted
time: 0ms
memory: 4240kb
input:
8 9 3 215521602 492908007 261206435 521145497 259750366 553629902 997991039 523071946 767416953 56767036
output:
450775894
result:
ok single line: '450775894'
Test #3:
score: 5
Accepted
time: 1ms
memory: 4176kb
input:
8 9 5 396559700 356016879 796231055 117198018 986043211 5573279 915325714 896890982 238440937 772820521
output:
34463958
result:
ok single line: '34463958'
Test #4:
score: 5
Accepted
time: 1ms
memory: 4172kb
input:
8 9 8 823551883 246279514 512316795 50015811 596048859 634297559 357816173 172030638 277258510 920803140
output:
650836255
result:
ok single line: '650836255'
Test #5:
score: 5
Accepted
time: 2ms
memory: 4820kb
input:
30 7 5 277343567 231557726 518417466 839831772 308153685 661255375 10400942 137452650
output:
570273281
result:
ok single line: '570273281'
Test #6:
score: 5
Accepted
time: 2ms
memory: 4672kb
input:
30 7 6 769481383 218933928 397917786 715817994 28458205 1741468 432666671 767453624
output:
802897416
result:
ok single line: '802897416'
Test #7:
score: 5
Accepted
time: 2ms
memory: 5992kb
input:
30 7 9 560097542 225678652 985380091 657360686 588960965 286023927 39451645 813153395
output:
200784526
result:
ok single line: '200784526'
Test #8:
score: 5
Accepted
time: 0ms
memory: 5908kb
input:
30 12 7 233649570 882345965 363522936 697518226 276565878 305171861 862016201 694650802 295202855 895115917 87982489 198145962 118457524
output:
191413880
result:
ok single line: '191413880'
Test #9:
score: 5
Accepted
time: 0ms
memory: 5324kb
input:
30 12 8 280972635 121394003 96961086 311593799 16824904 872035232 806270513 706873478 838387709 911762507 518375946 363189973 93846934
output:
878193241
result:
ok single line: '878193241'
Test #10:
score: 5
Accepted
time: 4ms
memory: 5324kb
input:
30 12 14 33118764 570808334 277911327 206225040 739764940 873120222 787166401 297143172 542645907 209959496 558572198 749568456 492469905
output:
8638776
result:
ok single line: '8638776'
Test #11:
score: 5
Accepted
time: 8ms
memory: 15560kb
input:
30 100 1 280989359 685610909 652483091 218262426 612187297 933993851 128465889 118119862 758459128 482869427 840417548 996214463 836110953 8956015 894945622 619560556 219818505 29451496 358272495 696206257 230342287 851588985 859573270 833968093 763204877 853785448 282969832 273841812 923102044 4584...
output:
918455864
result:
ok single line: '918455864'
Test #12:
score: 5
Accepted
time: 8ms
memory: 15568kb
input:
30 100 1 238187011 269812145 373797704 493559311 525459197 494840062 127348462 781447685 540053429 448451906 15397875 202443100 38732140 40023578 278484005 462334159 562679988 736926803 282626752 723781472 662277299 358863810 27984540 832197799 962665975 699557436 986649610 436908753 320494341 95769...
output:
524381135
result:
ok single line: '524381135'
Test #13:
score: 5
Accepted
time: 8ms
memory: 15564kb
input:
30 100 1 624756242 578099224 322063599 955163372 527409783 886224870 196768173 678404094 71254380 400463809 462704961 522697398 174568824 839996207 181664607 564129436 324853491 954240664 279841814 134343701 734819121 855324702 517923195 647253253 321867400 801360468 25886504 866237487 301424065 286...
output:
483241545
result:
ok single line: '483241545'
Test #14:
score: 5
Accepted
time: 0ms
memory: 5004kb
input:
5 50 2 254286688 725442098 427960764 796779405 986706963 905854411 818897107 964334286 867743930 583810772 621078041 875275863 94943935 993613474 699229610 139437533 160785883 74877034 8820884 154629232 776225564 385632450 792900606 570001565 857615216 758514611 34346579 426872784 329305393 59552423...
output:
816583992
result:
ok single line: '816583992'
Test #15:
score: 5
Accepted
time: 0ms
memory: 4880kb
input:
5 50 3 398838269 62831191 767680179 548733975 555826543 359315797 126732814 236236917 736299966 477904769 853166426 287461631 463135258 178798437 997403650 87158184 572906600 697966474 960138109 242347816 879956491 777432793 390570007 708647774 714109560 612901589 377307686 585724634 560144176 50107...
output:
937159818
result:
ok single line: '937159818'
Test #16:
score: 5
Accepted
time: 7ms
memory: 10036kb
input:
15 100 8 537276628 100186052 185892981 934916070 567805882 918515644 431750302 796355931 218646822 867528879 340335349 895838502 324783806 28262471 36921137 16069248 30657555 649491332 119673208 552651140 623025591 114876021 403198375 59453768 518635907 617927870 217741861 573018213 950960313 720041...
output:
272087880
result:
ok single line: '272087880'
Test #17:
score: 5
Accepted
time: 6ms
memory: 7368kb
input:
30 30 15 60466183 610467381 171141086 693914857 963904829 564659588 530320949 440079007 365069705 829699120 283564411 328402092 300168872 613261423 746486046 10288211 360128573 745361137 454560349 807372883 536663856 136356261 883801886 164316038 21520306 943453842 666136933 543391844 857298855 3384...
output:
72174927
result:
ok single line: '72174927'
Test #18:
score: 5
Accepted
time: 12ms
memory: 7428kb
input:
30 30 27 791704008 141733617 624846593 851709929 992710617 212811783 633109877 793261502 936354310 396919562 836912348 231815656 963288997 740034788 423011666 759150033 384434935 683576701 853721112 420009380 582576185 749031968 9524373 451203892 109835437 775487403 621839989 303055045 36699775 3463...
output:
253611021
result:
ok single line: '253611021'
Test #19:
score: 5
Accepted
time: 47ms
memory: 15596kb
input:
30 100 16 875698537 331313447 201148316 859357152 75556427 84009302 29165462 183164679 801095477 362574916 174220357 904633392 840544725 26263814 209015337 148424354 181158359 130045322 130726397 756114144 893268484 890267565 401189740 163241681 937879687 734913073 137564816 583877304 334189462 8327...
output:
221099086
result:
ok single line: '221099086'
Test #20:
score: 5
Accepted
time: 63ms
memory: 15568kb
input:
30 100 21 316605536 504649194 334973924 478542137 897005201 967219463 982199815 294027518 578515247 444956501 169932813 517443072 608712080 853574514 517686368 318771389 413578320 648466530 224572747 536246850 615211381 271710227 740813454 795114103 726388592 324201075 793546883 933899825 539137621 ...
output:
483943039
result:
ok single line: '483943039'
Extra Test:
score: 0
Extra Test Passed