考虑高维前缀和,可以把每一维前缀和
比如:三维前缀和
for(i=1; i<=a; i++)
for(j=1; j<=b; j++)
for(k=1; k<=c; k++)
f[i][j][k] += f[i-1][j][k];
for(i=1; i<=a; i++)
for(j=1; j<=b; j++)
for(k=1; k<=c; k++)
f[i][j][k] += f[i][j-1][k];
for(i=1; i<=a; i++)
for(j=1; j<=b; j++)
for(k=1; k<=c; k++)
f[i][j][k] += f[i][j][k-1];
考虑子集和,可以状压,然后高维前缀和
for(i=0; i<N; i++)
for(j=0; j<1<<N; j++)
if(j & (1<<i)) f[j] += f[j ^ (1<<i)];
标签:前缀,状压,子集,一维,考虑,高维
From: https://www.cnblogs.com/gzyakioi/p/17722450.html