Advertisement
cupsamada

magic

Feb 6th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int a[501][501];
  4. int main()
  5. {
  6. int n, i, j, sa=0, s=0, ok=0, dp, ds, x;
  7. cin>>n;
  8. for(j=1; j<=n; j++)
  9. {
  10. cin>>a[1][j];
  11. sa=sa+a[1][j];
  12.  
  13. }
  14. dp=a[1][1];
  15. ds=a[1][n];
  16. for(i=2; i<=n; i++)
  17. {
  18. for(j=1; j<=n; j++)
  19. {
  20. cin>>a[i][j];
  21. x=a[i][j];
  22. s=s+x;
  23. if(i==j)
  24. {
  25. dp=dp+x;
  26. }
  27. if(i+j == 1+n)
  28. {
  29. ds=ds+x;
  30. }
  31. if(sa==s)
  32. {
  33. ok=0;
  34. }
  35. else
  36. {
  37. ok++;
  38. }
  39. }
  40. if(ok==0)
  41. {
  42. sa=s;
  43. s=0;
  44. }
  45.  
  46. }
  47. if(ok==0 && ds==sa && dp==sa)
  48. {
  49. cout<<"true";
  50. }
  51. else
  52. {
  53. cout<<"false";
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement