fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define el "\n"
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define se second
  7. #define fi first
  8. #define be begin()
  9. #define en end()
  10. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  11.  
  12. int main()
  13. {
  14. Faster;
  15. int n; cin >> n;
  16. int a[n][n];
  17. int dem = 1;
  18. ll ans = 0;
  19. for(int i = 0; i < n; i++)
  20. {
  21. for(int j = 0; j < n; j++)
  22. {
  23. a[i][j] = dem ++;
  24. //cout << a[i][j] << " ";
  25. if(i == j) ans += a[i][j];
  26. }
  27. //cout << el;
  28. }
  29. cout << ans;
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5288KB
stdin
4
stdout
34