Cod sursa(job #1265483)

Utilizator beldeabogdanBogdan Beldea beldeabogdan Data 17 noiembrie 2014 12:53:47
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <cstdio>
#include <algorithm>
#define buflen 10000
using namespace std;

int answer;
int n;
long long shmen[50005];
int shmenPos;
char buf[buflen];
int bufpos = buflen;

char getch()
{
	if (bufpos >= buflen)
	{
		fread(buf,1,buflen,stdin);
		bufpos = 0;
	}
	return buf[bufpos++];
}

inline bool isNumber(char a)
{
	return '0' <= a && a <= '9';
}

long long BISRead()
{
	long long aux = 0;
	char ct = getch();
	while (!isNumber(ct)) ct = getch();
	while (isNumber(ct))
	{
		aux = 10 * aux + ct - '0';
		ct = getch();
	}
	return aux;
}

int main()
{
	freopen("dtcsu.in","r",stdin);
	freopen("dtcsu.out","w",stdout);
	for (int i=1;i <= 276997;i++)
	{
		int aux = BISRead();
		if (!(aux&1)) shmen[shmenPos++] = aux;
	}
	sort(shmen,shmen+shmenPos);
	
	n = BISRead();
	for (int i=1;i<=n;i++)
	{
		int ct = BISRead();
		while (!(ct&1)) ct >>= 1;
		long long* p = lower_bound(shmen,shmen+shmenPos,ct);
		if (ct == *p) answer++;
	}
	printf("%d\n",answer);
	return 0;
}