fork download
  1. /*
  2. Task: Problem 7.05
  3. Date: Dec 24, 2020
  4. Author: aLittleLove (Minh Vu)
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  14. //freopen("input.txt","r",stdin);
  15. int n; cin >> n >> n;
  16. double sum = 0;
  17. for (int i=0; i<n; i++)
  18. {
  19. for (int j=0; j<n; j++)
  20. {
  21. double x; cin >> x;
  22. if (i==j) sum += x;
  23. }
  24. }
  25. cout << sum;
  26. return 0;
  27. }
Success #stdin #stdout 0s 4700KB
stdin
5 5
0 6 8 9 2
2 5 5 8 3
3 1 0 2 8
8 9 3 4 9
1 3 7 6 2
stdout
11