Files
luogu/P17538.cpp
T
2026-10-01 23:47:16 +08:00

25 lines
602 B
C++

#include <bits/stdc++.h>
using namespace std;
int t;
int n; // 2000
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (i == j) {
printf("%d ", i);
} else if (i % j == 0) {
printf("%d ", j);
} else if (j % i == 0) {
printf("%d ", i);
} else {
printf("1 ");
}
}
putchar('\n');
}
}
return 0;
}