Advertisement
Saleh127

CF gym100735E

Oct 30th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll a[105][105],b,c=0,d,e,i,j,k;
  11. cin>>b;
  12. for(i=1;i<=b;i++)
  13. {
  14. for(j=1;j<=b;j++)
  15. {
  16. cin>>a[i][j];
  17. c+=a[i][j];
  18. }
  19. }
  20.  
  21. d=c/(b-1);
  22.  
  23. for(i=1;i<=b;i++)
  24. {
  25. for(j=1;j<=b;j++)
  26. {
  27. if(a[i][j]==0)
  28. {
  29. e=d;
  30. for(k=1;k<=b;k++)
  31. {
  32. e-=a[k][i];
  33. }
  34. cout<<e<<" ";
  35. }
  36. else cout<<a[i][j]<<" ";
  37. }
  38. cout<<endl;
  39. }
  40. return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement