Submission #74105

#TimeUsernameProblemLanguageResultExecution timeMemory
74105charlies_mooProsjecni (COCI16_prosjecni)C++17
120 / 120
4 ms504 KiB
#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; }

Compilation message (stderr)

prosjecni.cpp: In function 'int main()':
prosjecni.cpp:5:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...