new file: P17538.cpp

This commit is contained in:
hanyixuanten committed 2026-10-01 23:47:16 +08:00
1 parent 583e98bd69
commit 2b5e1ffdab
3 files changed
+105

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
#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;
}