Cod sursa(job #1265513)

Utilizator beldeabogdanBogdan Beldea beldeabogdan Data 17 noiembrie 2014 13:19:13
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <fstream>
#include <algorithm>
#define buflen 10000
using namespace std;

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

ifstream f("dtcsu.in");
ofstream g("dtcsu.out");

char getch()
{
	if (bufpos >= buflen)
	{
		f.read(buf,buflen);
		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()
{
	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++)
	{
		long long ct = BISRead();
		while (!(ct&1)) ct >>= 1;
		long long* p = lower_bound(shmen,shmen+shmenPos,ct);
		if (ct == *p) answer++;
	}
	g << answer;
	return 0;
}