You are given NXM table. Each cell of the table is colored white or black. Find the number of non-empty sets of cells such that:all cells in a set have the same color. Every two cells in a set share row or column. Input
The "a" of input contains integers n and m (1≤n, m≤50)-the number of rows and the number of columns Correspon dingly.
The next n lines of input contain descriptions of rows. There are m integers, separated by spaces. The number equals 0 if the corresponding cell is colored white and equals 1 if the corresponding cell was colored black. Output
Output single integer-the number of non-empty sets from problem description.
Violence law.
First violence in each row, for each row of statistics there are several white X. Each piece may choose not to choose, therefore chooses the white the choice method to have POW (2,x)-1. Black has POW (2,m-x)-1 options.
Calculate each column in the same vein.
But we have a situation in both rows and columns, which is to enumerate only one piece as a collection of selections. So this is repeated, repeating the n*m. So minus n*m.
#include <cstdio>
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace Std;
int a[100][100];
int n,m;
int main ()
{
cin>>n>>m;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
Long Long ans=0;
for (int i=0;i<n;i++)
{
int geshu=0;
for (int j=0;j<m;j++)
{
if (A[i][j])
{
geshu++;
}
}
Ans=ans+pow (2,geshu) +pow (2,m-geshu)-2;
}
for (int i=0;i<m;i++)
{
int geshu=0;
for (int j=0;j<n;j++)
{
if (A[j][i])
{
geshu++;
}
}
Ans=ans+pow (2,geshu) +pow (2,n-geshu)-2;
}
cout<<ans-n*m<<endl;
}