QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#573100#5097. 小 P 爱学习ANIG0 1094ms37316kbC++141.5kb2024-09-18 17:21:432024-09-18 17:21:44

Judging History

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

  • [2024-09-18 17:21:44]
  • 评测
  • 测评结果:0
  • 用时:1094ms
  • 内存:37316kb
  • [2024-09-18 17:21:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1505,M=105,T=40,G=1.5e5+5,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][N],g[N][N],rs[N][N],dp[2][G],n,m,jc[G],ny[G],p[G],res;
int C(int a,int b){
	return jc[a]*ny[b]%mods*ny[a-b]%mods;
}
signed main(){
	cin>>n>>m;
	n*=m;
	jc[0]=ny[0]=1;
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%mods,ny[i]=pows(jc[i],mods-2);
	for(int i=1;i<=n;i++)cin>>p[i];
	f[0][0]=g[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-(j-1)*(m-1)&&k<m-1+T*m;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;
			}
		}
	}
	for(int j=1;j<=n/m&&j<=T;j++){
		for(int i=j*(m-1);i<=n;i+=m){
			for(int k=m-1+T*m;k<=i-(j-1)*(m-1);k+=m){
				g[(i-j*(m-1))/m][j]+=g[(i-k-(j-1)*(m-1))/m][j-1]*C(i,k);
				g[(i-j*(m-1))/m][j]%=mods;
			}
		}
	}
	for(int j=1;j<=n/m;j++){
		for(int a=0;a<=j&&a<=T;a++){
			for(int b=a*(m-1);b<=n-(j-a)*(m-1);b+=m){
				rs[(n-j-j*(m-1))/m][j]+=g[(b-a*(m-1))/m][a]*f[(n-j-b-(j-a)*(m-1))/m][j-a]%mods*C(j,a)%mods*C(n-j,b);
				rs[(n-j-j*(m-1))/m][j]%=mods;
			}
		}
	}
	for(int i=0;i<=n;i++)dp[0][i]=1;
	return 0;
	for(int i=1;i<=n/m;i++){
		dp[1][0]=0;
		for(int j=1;j<=n;j++){
			dp[1][j]=dp[1][j-1]+dp[0][j-1]*p[j];
			dp[1][j]%=mods;
		}
		res+=dp[1][n]*rs[n/m-i][i];
		res%=mods;
		swap(dp[1],dp[0]);
	}
	cout<<res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9876kb

input:

3 4
993987920 851664708 532496582 332334976 645105194 437392477 101400616 97233810 821968468 15736516 160047245 366079295

output:


result:

wrong output format Unexpected end of file - int32 expected

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
Wrong Answer

Test #11:

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

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:

wrong output format Unexpected end of file - int32 expected

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 105ms
memory: 18516kb

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:

wrong output format Unexpected end of file - int32 expected

Subtask #5:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 1094ms
memory: 37316kb

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...

output:


result:

wrong output format Unexpected end of file - int32 expected