Pagini recente » Cod sursa (job #709393) | Cod sursa (job #3127911) | Cod sursa (job #959051) | Cod sursa (job #2928470) | Cod sursa (job #1038660)
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
typedef long long Int;
const int n = 276997;
long long nq;
int sol;
const int mod = 666013;
vector<Int> H[mod];
inline void add(const Int &value)
{
const int line = value % mod;
for (vector<Int>::iterator it = H[line].begin(); it != H[line].end(); ++it)
{
if (*it == value)
{
return ;
}
}
H[line].push_back(value);
}
inline bool take(const Int &value)
{
const int line = value % mod;
for (vector<Int>::iterator it = H[line].begin(); it != H[line].end(); ++it)
{
if (*it == value)
{
return true;
}
}
return false;
}
const int buffer_size = 1024 * 1024;
char buff[buffer_size];
inline bool is_digit(const char &ch)
{
if ('0' <= ch && ch <= '9')
{
return true;
}
return false;
}
inline void next_long_long(long long &number)
{
static int i = buffer_size;
if (i == buffer_size)
{
fread(buff, buffer_size, 1, stdin);
i = 0;
}
while (!is_digit(buff[i]))
{
if (++i == buffer_size)
{
fread(buff, buffer_size, 1, stdin);
i = 0;
}
}
while (is_digit(buff[i]))
{
number = number * 10LL + buff[i] - '0';
if (++i == buffer_size)
{
fread(buff, buffer_size, 1, stdin);
i = 0;
}
}
}
int main()
{
freopen("dtcsu.in", "r", stdin);
for (int i = 1; i <= n; ++i)
{
Int foo = 0;
next_long_long(foo);
add(foo);
}
next_long_long(nq);
for (int i = 1; i <= nq; ++i)
{
Int foo = 0;
next_long_long(foo);
sol = sol + take(foo);
}
ofstream fout("dtcsu.out");
fout << sol << '\n';
}