#define FOR(i,s,t) for(int i=(s);i<=t;++i) void expand(int i, int& b0, int& b1, int& b2) { b0 = i&1; i >>= 1; b1 = i&1; i >>= 1; b2 = i&1; } int sign(int b0, int b1, int b2) { return (b0 + b1 + b2) % 2 == 1 ? 1 : -1; } { FOR(x,1,a) FOR(y,1,b) FOR(z,1,c) FOR(i,1,7) { expand(i, b0, b1, b2);//计算前缀和系数 S[x][y][z] += S[x-b0][y-b1][z-b2] * sign(b0, b1, b2);//确定正负 } }