标签:acm
const int MAXN = 801; bitset<MAXN> r1[MAXN], r2[MAXN], c1[MAXN], c2[MAXN]; int a[MAXN][MAXN]; int main() { int n; while (~RI(n)) { REP(i, n) REP(j, n) { RI(a[i][j]); if (a[i][j] >= 3) a[i][j] %= 3; r1[i][j] = a[i][j] >> 1; r2[i][j] = a[i][j] & 1; } REP(i, n) REP(j, n) { RI(a[i][j]); if (a[i][j] >= 3) a[i][j] %= 3; c1[j][i] = a[i][j] >> 1; c2[j][i] = a[i][j] & 1; } REP(i, n) REP(j, n) { a[i][j] = (r1[i] & c1[j]).count() ; a[i][j] += ((r1[i] & c2[j]).count()) << 1; a[i][j] += ((r2[i] & c1[j]).count()) << 1; a[i][j] += (r2[i] & c2[j]).count() ; if (a[i][j] >= 3) a[i][j] %= 3; } REP(i, n) REP(j, n) printf("%d%c", a[i][j], j == n - 1 ? '\n' : ' '); } return 0; }
Matrix multiplication,布布扣,bubuko.com
标签:acm
原文地址:http://blog.csdn.net/wty__/article/details/38542489