Pagini recente » Cod sursa (job #1708640) | Cod sursa (job #2270833) | Cod sursa (job #121696) | Cod sursa (job #167828) | Cod sursa (job #2477372)
//#include "pch.h"
#include <fstream>
#include <vector>
using namespace std;
class InParser {
private:
static const int buffSZ = (1 << 15);
ifstream File;
int buffPos;
char buff[buffSZ];
void _advance() {
if (++buffPos == buffSZ) {
File.read(buff, buffSZ);
buffPos = 0;
}
}
public:
InParser(const char *FileName) {
File.open(FileName);
buffPos = buffSZ - 1;
}
InParser& operator >>(long long &no) {
while (!isdigit(buff[buffPos]))
_advance();
no = 0;
while (isdigit(buff[buffPos])) {
no = no * 10 + buff[buffPos] - '0';
_advance();
}
return *this;
}
};
class HashMap {
private:
static const int Mod = 10003;
vector <long long> hash[Mod];
public:
HashMap() {}
bool search(const long long &val) {
long long key = val % Mod;
for (const long long &itm : hash[key])
if (itm == val)
return true;
return false;
}
void add(const long long &val) {
if (search(val))
return;
hash[val % Mod].push_back(val);
}
}hashmap;
InParser fin("dtcsu.in");
ofstream fout("dtcsu.out");
int main() {
for (int x = 276997; x; --x) {
long long no;
fin >> no;
hashmap.add(no);
}
long long Q;
fin >> Q;
int cnt = 0;
for (; Q; --Q) {
long long no;
fin >> no;
if (hashmap.search(no)) ++cnt;
}
fout << cnt;
}