# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82384 | 2018-10-30T11:26:07 Z | farukkastamonuda | Prosjecni (COCI16_prosjecni) | C++14 | 0 ms | 0 KB |
prosjecni #include <cstdio> int main() { int n; scanf("%d", &n); if (n == 2) { printf("-1\n"); } else if (n % 2 == 1) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { printf("%d%c", i*n+j+1, j==n-1 ? '\n' : ' '); } } } else { int k = n / 2; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - 1; j++) { printf("%d ", 3*k*i+j+1); } printf("%d\n", 3*k*(i+1)); } for (int j = 0; j < n - 1; j++) { printf("%d ", 9*k*k-3*k+j+1); } printf("%d\n", 9*k*k); } return 0; }