[2016-04-06][codeforces][629][A][Far Relative’s Birthday Cake]
时间:2016-04-06 18:04:56 星期三
题目编号:[2016-04-06][codeforces][629][A][Far Relative’s Birthday Cake]
题目大意:同行或者同列的东西有多少对
#include <cstdio>
using namespace std;
int main(){
int n;
char str[110];
scanf("%d",&n);
int ans = 0,c[110] = {0},cur;
for(int i = 0;i < n ; ++i){
scanf("%s",str);
cur = 0;
for(int j = 0;j < n ;++j){
if(str[j] == 'C'){
++cur;
++c[j];
}
}
if(cur) ans += (cur * (cur - 1))/2;
}
for(int i = 0; i < n ; ++i){
if(c[i]) ans += c[i] * (c[i] - 1) / 2;
}
printf("%d\n",ans);
return 0;
}