测测你的矩阵乘法

Luogu
IDLGB3615
Time1000ms
Memory128MB
DifficultyP2
数学O2优化
给定两个大小为均为 $512 \times 512$,每个元素均为整数,值域为 $ [0, 1024) $ 矩阵 $A, B$,定义为 $$ \begin{aligned} A\left[i, j\right] &= \left(\left(i \mathbin{\mathrm{or}} j\right) + j\right) \mathbin{\mathrm{xor}} \mathrm{seed}_A \\ B\left[i, j \right] &= \left( \left(i \mathbin{\mathrm{and}} j \right) + i \right) \mathbin{\mathrm{xor}} \mathrm{seed}_B \end{aligned} $$ 其中 $i, j \in [0, 512)$。 请计算 $C = A \times B$。 ## Input 输入为两个整数 $\mathrm{seed}_A, \mathrm{seed}_B$($0 \leq \mathrm{seed}_A, \mathrm{seed}_B < 1024$)。 你可以使用以下代码模板,完成其中的 `multiply` 即可。 你可以修改 $N$(即数组长度),但是不能修改 $n$(矩阵大小,恒为 $512$)。 ```cpp #include <bits/stdc++.h> const int n = 512, N = n; void multiply (int c[N][N], int a[N][N], int b[N][N]) { // c = a * b } int c[N][N], a[N][N], b[N][N]; int main() { int seedA, seedB; scanf("%d%d", &seedA, &seedB); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) a[i][j] = ((i | j) + j) ^ seedA; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) b[i][j] = ((i & j) + i) ^ seedB; multiply(c, a, b); for (int i = 0; i < n; i++) { int sum = 0; for (int j = 0; j < n; j++) sum ^= c[i][j]; printf("%d\n", sum); } } ``` ## Output 输出 $512$ 行,分别是 $C$ 每行的异或和。 输入中的代码会帮助你完成输出。 [samples]
Samples
Input #1
0 0
Output #1
8126464
14942208
33554432
...(省略506行)
29097984
146800640
148570112
API Response (JSON)
{
  "problem": {
    "name": "测测你的矩阵乘法",
    "description": {
      "content": "给定两个大小为均为 $512 \\times 512$,每个元素均为整数,值域为 $ [0, 1024) $ 矩阵 $A, B$,定义为 $$ \\begin{aligned} \tA\\left[i, j\\right] &= \\left(\\left(i \\mathbin{\\mathrm{or}} j\\right) + j\\right) \\mathbin{\\mathrm{xor}} \\mathrm{se",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P2"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGB3615"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "给定两个大小为均为 $512 \\times 512$,每个元素均为整数,值域为 $ [0, 1024) $ 矩阵 $A, B$,定义为\n\n$$ \\begin{aligned}\n\tA\\left[i, j\\right] &= \\left(\\left(i \\mathbin{\\mathrm{or}} j\\right) + j\\right) \\mathbin{\\mathrm{xor}} \\mathrm{se...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments