QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72143#4812. Counting SequenceAppleblue17RE 0ms0kbC++14742b2023-01-14 15:17:292023-01-14 15:17:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-14 15:17:31]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-01-14 15:17:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=3e4+5,B=880,mod=998244353;
int n,m=880,c,ans;

int f[B][N];
int g[N][B*2];

int main(){
	cin>>n>>c;
	f[1][m]=1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j+m+i<=n) f[i+1][j+m+i]=(f[i+1][j+m+i]+f[i][j])%mod;
			f[i+1][j+m-i]=(f[i+1][j+m-i]+1ll*f[i][j]*c%mod)%mod;
		}
	}
	for(int t=m;t<=n;t++)
		for(int i=1;i<=m && (t-m)*i<=n;i++)
			ans=(ans+f[i][n-(t-m)*i])%mod;
	
	for(int t=1;t<m;t++) g[t][t]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=2*m;j++){
			if(j>1) g[i+j-1][j-1]=(g[i+j-1][j-1]+1ll*g[i][j]*c%mod)%mod;
			if(i+j+1<=n) g[i+j+1][j+1]=(g[i+j+1][j+1]+g[i][j])%mod;
		}
	}
	for(int t=1;t<=2*m;t++) ans=(ans+g[n][t])%mod;
	cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

5 3

output:


result: