QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#572801 | #5097. 小 P 爱学习 | ANIG | 10 | 5ms | 6156kb | C++14 | 1.0kb | 2024-09-18 16:26:42 | 2024-09-18 16:26:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1505,M=105,mods=1e9+7;
int pows(int a,int b){
if(b==0)return 1;
int res=pows(a,b>>1);
res=res*res%mods;
if(b&1)res=res*a%mods;
return res;
}
int f[N][M],n,m,C[N][N],cnt[N],p[N],res;
signed main(){
cin>>n>>m;
n*=m;
for(int i=1;i<=n;i++)cin>>p[i];
for(int i=0;i<=n;i++)C[i][0]=1;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
C[i][j]=(C[i-1][j-1]+C[i-1][j])%mods;
}
}
f[0][0]=1;
for(int j=1;j<=n/m;j++){
for(int i=j*(m-1);i<=n;i+=m){
for(int k=m-1;k<=i;k+=m){
f[(i-j*(m-1))/m][j]+=f[(i-k-(j-1)*(m-1))/m][j-1]*C[i][k];
f[(i-j*(m-1))/m][j]%=mods;
}
// cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
}
}
for(int i=1;i<(1<<n);i++){
cnt[i]=cnt[i&-i^i]+1;
int sm=1;
for(int j=1;j<=n;j++){
if(i>>j-1&1^1)continue;
sm=sm*p[j]%mods;
}
if((n-cnt[i]-cnt[i]*(m-1))%m==0)res+=sm*f[(n-cnt[i]-cnt[i]*(m-1))/m][cnt[i]];
res%=mods;
// cout<<i<<" "<<sm<<" "<<cnt[i]<<" "<<res<<endl;
}
cout<<res;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3664kb
input:
3 4 993987920 851664708 532496582 332334976 645105194 437392477 101400616 97233810 821968468 15736516 160047245 366079295
output:
856280467
result:
ok answer is 856280467
Test #2:
score: 10
Accepted
time: 0ms
memory: 3692kb
input:
2 2 410797770 6809338 472422778 989528224
output:
428410815
result:
ok answer is 428410815
Test #3:
score: 10
Accepted
time: 0ms
memory: 3752kb
input:
1 2 61861880 797258571
output:
859120451
result:
ok answer is 859120451
Test #4:
score: 10
Accepted
time: 5ms
memory: 6156kb
input:
4 4 345828253 333235310 877508155 268177944 892729462 591630803 103568022 189412379 473190308 606582845 39234531 676920516 526713342 584876596 477385922 911117054
output:
130539277
result:
ok answer is 130539277
Test #5:
score: 10
Accepted
time: 1ms
memory: 5784kb
input:
3 4 497837179 320032498 88408654 686869221 955729904 891421702 840622668 700545094 994455042 397227737 872911626 764923114
output:
444700147
result:
ok answer is 444700147
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
input:
1500 1 613884366 318223729 617843443 151365784 314748737 778479063 762692152 762329264 560579744 428619194 148701427 891734077 339222910 692588908 180829596 615884679 688697194 981930569 856072945 973079346 407508504 185723413 482150672 944412007 548582506 572572951 297202679 276708377 552007154 951...
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #11:
score: 0
Runtime Error
input:
100 42 544703372 456304555 178333752 808160596 628160657 264931494 810502429 20342061 203372934 920107110 466566652 470361058 680819469 879463750 668822108 781685938 40434324 800845096 913025163 971899062 986502509 122277391 523016525 579121406 413351231 882719635 632511496 453222515 350376424 37340...
output:
result:
Subtask #4:
score: 0
Runtime Error
Test #16:
score: 0
Runtime Error
input:
499 60 136856769 47869549 264538291 600887500 271130365 503375271 979728502 928286478 295751844 413206031 143796624 712745939 41348750 488666164 725432432 529794914 703056452 573552365 225245406 620490759 715276073 987544150 759181034 939466746 354701446 228245827 301255190 24876250 452483821 837389...
output:
result:
Subtask #5:
score: 0
Runtime Error
Test #21:
score: 0
Runtime Error
input:
1500 93 299567650 399978478 101776752 583392666 56762099 127237968 595272440 581887945 332400603 269986805 17840600 323055242 263161884 607605816 966029729 591250421 964262680 642691696 658567473 339363823 715151825 270553684 202478735 193930303 14517687 248178770 917823665 315265457 473654173 33965...