Cod sursa(job #1043849)

Utilizator raulstoinStoin Raul raulstoin Data 28 noiembrie 2013 23:21:44
Problema Dtcsu Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.01 kb
#include<fstream>
#include<algorithm>
#include<vector>

#define NMAX 276997
#define LL long long
#define ULL unsigned LL

using namespace std;

ifstream fin("dtcsu.in");
ofstream fout("dtcsu.out");

int q,sol;
LL n,nr;
vector<LL> v;
const int index64[64] = {
    0,  1, 48,  2, 57, 49, 28,  3,
   61, 58, 50, 42, 38, 29, 17,  4,
   62, 55, 59, 36, 53, 51, 43, 22,
   45, 39, 33, 30, 24, 18, 12,  5,
   63, 47, 56, 27, 60, 41, 37, 16,
   54, 35, 52, 21, 44, 32, 23, 11,
   46, 26, 40, 15, 34, 20, 31, 10,
   25, 14, 19,  9, 13,  8,  7,  6
};

const int SZ=100000;
char input[SZ+1],*in;

inline int bitScanForward(ULL bb) {
   const ULL debruijn64 = 0x03f79d71b4cb0a89LL;
   return index64[((bb & -bb) * debruijn64) >> 58];
}

int main()
{
	for(int i=0;i<NMAX;i++)
	{
		fin>>n;
		if(!(n&1))
			continue;
		v.push_back(n);
	}
	sort(v.begin(),v.end());
	fin>>q;
	for(;q;q--)
	{
		fin>>n;
		n>>=bitScanForward(n);
		sol+=(binary_search(v.begin(),v.end(),n));
	}
	fout<<sol;
	return 0;
}