Pagini recente » Cod sursa (job #2663574) | Cod sursa (job #1859957) | Profil EugenStoica | Istoria paginii runda/mircealinkuu/clasament | Cod sursa (job #2452318)
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f ("abc2.in");
ofstream g ("abc2.out");
string s;
string t;
long long a,b;
vector<long long > vek;
long long lenstr, texlen;
int main()
{
f>>s;
while(f>>t)
{
lenstr=t.size();
a=0;
for(long long i=0;i<=t.size()-1;++i)
{
a*=3;
a+=t.at(i)-'a';
}
vek.push_back(a);
// g<<a<<" "<<t<<"\n ";
}int pow=1;
for(int i=0;i<lenstr;++i)
{
pow*=3;
}
texlen=s.size();
long long nr=0;
b=0;
for(long long i=0;i<texlen;++i)
{
b*=3;
b+=s.at(i)-'a';
b%=pow;
if(i>=lenstr-1)
{
// g<<"b-> "<<b<<" "<<s<<"\n";
if(find(vek.begin(), vek.end(), b)!=vek.end())
nr++;
}
}
g<<nr;
return 0;
}