My issue
If we take each submatrices of 2X2 with all elements 0 and fill each of them with 1 one by one, then we will receive the value for each submatrix as 6. There will be NM/4 such submatrices and for each of them the solution will be 6. So according to my analysis it must be 6(nm)/4=3(n*m)/2.
My code
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n,m,a=0;
cin>>n>>m;
if(n%2!=0 && )
{
a+=(m/2)*(m/2+1)+(m/2)*(m/2-1);
}
a-=n+m;
cout<<3*(n*m)/2+a<<endl;
}
return 0;
}
Problem Link: Sum of Xors Practice Coding Problem