#include <bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
using namespace std;
int n;
int mat[100][100];
int arr[100];
int main(){
//freopen("baskent.gir", "r", stdin);
cin >> n;
if (n == 1){
cout << "1" << endl;
return 0;
} else if (n == 2){
cout << "-1" << endl;
return 0;
}
for (int i = 0; i < n-1; i++){
arr[i] = i+1;
}
arr[n-1] = (n-1)*(n-1) - (n-2)*(n-1)/2;
//for (int i = 0; i < n; i++) cout << arr[i] << " "; cout << endl;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
mat[i][j] = arr[i]*10000;
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
mat[i][j] += arr[j];
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cout << mat[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |