SHARE
TWEET

Untitled

a guest Feb 19th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@and
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int a[101][101],i,j,m,n;
  6. int div(int a[101][101], int l1, int c1, int l2, int c2)
  7. {
  8.     if(l1==l2)
  9.     {
  10.         int sol=0;
  11.         for(int j=c1;j<=c2;j++)
  12.         {
  13.             if(a[l1][j]%2==0) sol+=a[l1][j];
  14.         }
  15.         return sol;
  16.     }
  17.     else
  18.     {
  19.         int m1=(c1+c2)/2;
  20.         int m2=(l1+l2)/2;
  21.         return div(a,l1,c1,m2,m1)+div(a,l1,m1+1,m2,c2)+div(a,m2+1,c1,l2,m1)+div(a,m2+1,m1+1,l2,c2);
  22.     }
  23. }
  24. int main()
  25. {
  26.     cin>>m>>n;
  27.     for(i=1;i<=m;i++) for(j=1;j<=n;j++) cin>>a[i][j];
  28.     cout<<div(a,1,1,m,n);
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top