Pagini recente » Cod sursa (job #1189576) | Cod sursa (job #993149) | Cod sursa (job #2356314) | Cod sursa (job #2812707) | Cod sursa (job #98589)
Cod sursa(job #98589)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <map>
using namespace std;
const int N_MAX = 10000010;
const int L_MAX = 22;
char s[N_MAX], word[L_MAX], ver[L_MAX];
map <string, int> words;
string kkt;
char buf[1048576];
int main()
{
freopen("abc2.in", "r", stdin);
#ifndef _SCREEN_
freopen("abc2.out", "w", stdout);
#endif
setbuf(stdin, buf);
int l1;
fgets(s, sizeof(s), stdin);
fgets(word, L_MAX, stdin);
l1 = strlen(word) - 1;
word[l1] = '\0';
kkt = word;
words[kkt] = 1;
while (fgets(word, L_MAX, stdin)) {
word[l1] = '\0';
kkt = word;
words[kkt] = 1;
}
int l = strlen(s) - 1, nrp = 0, i, j;
for (i = 0; i <= l - l1; i ++) {
for (j = i; j < (i + l1); j ++) {
ver[j - i] = s[j];
}
kkt = ver;
if (words[kkt]) {
nrp ++;
}
}
printf("%d\n", nrp);
return 0;
}