QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72143 | #4812. Counting Sequence | Appleblue17 | RE | 0ms | 0kb | C++14 | 742b | 2023-01-14 15:17:29 | 2023-01-14 15:17:31 |
Judging History
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