hdu1251
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
string s;
map<string, int>mp;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while(getline(cin, s) && s != ""){
int len = s.size();
string str;
for (int i = 0; i < len; i++){
str += s[i];
mp[str]++;
}
}
while(cin >> s){
cout << mp[s] << endl;
}
return 0;
}
/**/
然后我随便用了map,不想用字典树