将条件转化为 i,j⩾0,i+j⩾k|Av+i,u+j+=(i+ji) i , j ⩾ 0 , i + j ⩾ k | A v + i , u + j + = ( i + j i ) , 考虑组合意义,从 (v,u) ( v , u ) 开始每次往右或往下走,走大于等于 k k <script type="math/tex" id="MathJax-Element-9">k</script>布的方案数,直接DP。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int tt=998244353,maxn=306;
int n,m,q,f[maxn][maxn][maxn*2];
LL x0;
int rnd(){x0=(x0*100000005+20150823)%tt;return x0/100;}
int main(){
freopen("B.in","r",stdin);freopen("B.out","w",stdout);
scanf("%d%d%d%lld",&n,&m,&q,&x0);
for(int i=1,v,u,k;i<=q;i++)v=rnd()%n+1,u=rnd()%m+1,k=rnd()%(n+m-v-u+1),f[v][u][k]++;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
(f[i+1][j][0]+=f[i][j][0])%=tt;(f[i][j+1][0]+=f[i][j][0])%=tt;
for(int k=1;k<=n+m;k++)(f[i+1][j][k-1]+=f[i][j][k])%=tt,(f[i][j+1][k-1]+=f[i][j][k])%=tt;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)printf("%d ",f[i][j][0]);
printf("\n");
}
return 0;
}