0%

Hdu1251 (字符串/Hash)

题目链接
注意对于换行符的操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

map<string, int> mp;

string s;

int main() {
int fff = 0;
while(getline(cin, s)) {
int len = s.length();
if(fff) {
cout << mp[s] << endl;
continue;
}
if(s.length() == 0) {
fff = 1;
continue;
}
string tmp = "";
for(int i = 0; i < len; i++) {
tmp += s[i];
//cout << tmp << endl;
mp[tmp]++;
}
}

return 0;
}
求大佬赏个饭