1 #include2 #include 3 #include 4 #include 5 #define sz 10010 6 #define ull unsigned long long 7 using namespace std; 8 int n, ans = 1; 9 const int base = 233;10 ull a[sz];11 char s[sz];12 ull hash(char s[]) {13 int len = strlen(s);14 ull ans = 0;15 for(int i = 0; i < len; i++) ans = (ans*base+(ull)s[i]);16 //一度不理解它怎么就转换成base进制的数了qaq不想承认自己是个傻子qaq17 return ans&0x7ffffff;18 }19 int main() {20 scanf("%d",&n);21 for(int i = 1; i <= n; i++) {22 scanf("%s",s);23 a[i] = hash(s);24 }25 sort(a+1,a+n+1);26 for(int i = 2; i <= n; i++) if(a[i] != a[i-1]) ans++;27 printf("%d",ans);28 return 0;29 }
orz dalao就是dalao!!!!!都能把我讲懂!!!!