fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N = 4096;
  5. int A[N][N];
  6.  
  7. int main() {
  8. // traversing a matrix in column major order
  9. for (int c=0; c<N; ++c) for (int r=0; r<N; ++r) A[r][c] = r+c;
  10. long long sum = 0;
  11. for (int loop=0; loop<5; ++loop) {
  12. for (int c=0; c<N; ++c) for (int r=0; r<N; ++r) sum += A[r][c];
  13. }
  14. cout << sum << endl;
  15. }
Success #stdin #stdout 4.89s 68928KB
stdin
Standard input is empty
stdout
343513497600