fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, suma = 0;
  6. cin >> n;
  7.  
  8. for (int i = 0; i < n; i++) {
  9. for (int j = 0; j < n; j++) {
  10. int x;
  11. cin >> x;
  12. if ((i + j) % n != 0 || (i != 1 && j != 2) && (i != 2 && j != 1)) {
  13. suma += x;
  14. }
  15. }
  16. }
  17.  
  18. cout << suma << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
2 5 3
5 3 4
8 4 5
stdout
31