fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 10;
  5.  
  6. int main() {
  7. int colSize, lineSize, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8. cin >> colSize >> lineSize;
  9. for (int line = 1; line <= colSize; ++line) {
  10. for (int col = 1; col <= lineSize; ++col) {
  11. cin >> mt[line][col];
  12. }
  13. }
  14. int xBegin, yBegin, xEnd, yEnd;
  15. cin >> xBegin >> yBegin >> xEnd >> yEnd;
  16. int sum = 0;
  17. for (int line = xBegin; line <= xEnd; ++line) {
  18. for (int col = yBegin; col <= yEnd; ++col) {
  19. sum += mt[line][col];
  20. //cout << "line = " << line << " col = " << col << " sum = " << sum << endl;
  21. }
  22. }
  23. cout << sum *-sum;
  24. return 0;
  25. }
Success #stdin #stdout 0s 5300KB
stdin
2 1
25
50
1 1 1 1
stdout
-625