#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
const int mod=1000000007;
const int p=10000019;
vector<int> ans;
long long hash(string str){ // 熟練書寫字符串哈希函數!
long long h=0;
for(int i=0;i<str.length();i++){
h=(h*p+str[i]-'a')%mod;
}
return h;
}
int main(){
string str;
while(getline(cin,str),str!="#"){
long long id=hash(str);
ans.push_back(id);
}
sort(ans.begin(),ans.end());
int count=0;
for(int i=0;i<ans.size();i++){
if(i==0||ans[i]!=ans[i-1]){
count++;
}
}
printf("%d\n",count);
return 0;
}
求不同字符串的個數
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.