作为一道水题,自然不用太难的做法。
思路
先写一个函数,每次传进一个字符串,用暴力枚举两个字符来判断两个是否有相同的字符,如果有,return false;。否则,return true;
然后,暴力枚举每个字符串,传进函数里,如果return true;,则答案加一。
代码:
#include<bits/stdc++.h>
using namespace std;
int n,f[30],l,ans;
char s[110][110];
inline bool clec(int x){
l = strlen(s[x] + 1);
for (int i = 1;i <= l;i++)
for (int j = 1;j <= l;j++){
if (i == j) continue;
if (s[x][i] == s[x][j]) return false;
}
return true;
}
int main(){
scanf("%d",&n);
for (int i = 1;i <= n;i++) scanf("%s",s[i] + 1);
for (int i = 1;i <= n;i++) ans += clec(i);
printf("%d\n",ans);
}