/**
 * 
 */
package 审美课;
import java.util.Scanner;
/**
 * @author 邢兵
 * @data
 * @description
 */
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int a[] = new int[n];
		long ans[] = new long[1100000];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				int temp;
				temp = in.nextInt();
				a[i] =(a[i]<<1)+temp;//2进制保存 
			}	
			ans[a[i]]++;//记录每种方案的人数
		} 
		int max = (1<<m)-1;
		int sum=0;
		for(int i=0;i<n;i++){
			int temp = a[i]^max;
			sum+=ans[temp];
		}
		System.out.println(sum/2);
	}
}
原文:https://www.cnblogs.com/xuesujun/p/12309164.html