玲珑杯 ACM热身赛 #2.5 A 记忆化搜索+瞎搞
#include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <map> #include <set> #include <list> #include <queue> #include <stack> #include <cmath> #include <cstring> #define N 998244353 #define LL long long int int n,m; using namespace std; LL dp[505][505]; LL dfs(int he,int qiu,int lim) { // if(n%m!=0&&lim==n/m+1) // return 0; if(he==0) { if(qiu!=0) return 0; else return 1; } if(dp[he][qiu]) return dp[he][qiu]; LL rec=0; for(int i=0;i<=qiu&&i<lim;i++) rec+=dfs(he-1,qiu-i,lim),rec%=N; dp[he][qiu]=rec; return rec; } int main() { cin.sync_with_stdio(false); cin>>n>>m; LL ans=0; for(int i=n;i>=0;i--) { memset(dp,0,sizeof(dp)); ans+=dfs(m-1,n-i,i),ans%=N; } cout<<ans*m%N<<endl; return 0; }