现在的位置: 首页 > 综合 > 正文

zoj 2975 Kinds of Fuwas

2012年10月07日 ⁄ 综合 ⁄ 共 444字 ⁄ 字号 评论关闭
#include "iostream"
#include "stdio.h"
#include "string"
using namespace std;

char num[260][260];
char fuwa[] = "BJHYN";

int main()
{
	int TestCase, i, j, k, n, count, total, M, N;
	cin >> TestCase;
	while (TestCase--)
	{
		total = 0;
		cin >> M >> N;
		for (i = 0; i < M; i++)
			scanf("%s", num[i]);

		for (i = 0; i < M; i++)//第一行的比较
			for (j = i + 1; j < M; j++)//第二行的比较
			{
				for (k = 0; k < 5; k++)//福娃的数目比较
				{
					count = 0;
					for (n = 0; n < N; n++)//列中的比较
					{
						if (num[i][n] == fuwa[k] && num[j][n] == fuwa[k])
							count++;
					}
					total += count * (count - 1) / 2;
				}
			}
		cout << total << endl;
	}
}

抱歉!评论已关闭.