The 5th Zhejiang Provincial Collegiate Programming Contest------ProblemK:Kinds of Fuwas

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1974

题意:问四个角都有同一个福娃的矩形有多少个。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 char aa[521][521],bb[5]= {'B','J','H','Y','N'};
 5 int main() {
 6     int t,n,m;
 7     int i,j,k,l,s,ss;
 8     cin>>t;
 9     while(t--) {
10         cin>>n>>m;
11         for(int =0; i<n; i++)
12             cin>>aa[i];
13         ss=0;
14         
15         for(l=0; l<5; l++) {//检查每一个福娃 
16             for(i=0; i<n; i++) {
17                 for(j=i+1; j<n; j++) {
18                     s=0;
19                     for(k=0; k<m; k++) {//检查两列中是否有相同的 
20                         if(a[i][k]==a[j][k]&&a[i][k]==bb[l])
21                             s++;
22                     }
23                 }
24                 ss+=s*(s-1)/2;//s个相同的能有s*(s-1)/2个矩阵 
25             }
26         }
27         cout<<ss<<endl;
28     }
29     return 0;
30 
31 }
我会一直在
原文地址:https://www.cnblogs.com/zhien-aa/p/5203269.html