Cod sursa(job #1058871)

Utilizator AlexandruValeanuAlexandru Valeanu AlexandruValeanu Data 15 decembrie 2013 22:12:59
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.25 kb
#include <iostream>
#include <fstream>
#include <unordered_set>

using namespace std;

unordered_set < long long > S;

#define BUF_SIZE 200000
char buffer[BUF_SIZE];
int position = BUF_SIZE;

inline char getChar()
{
    if ( position == BUF_SIZE )
    {
        fread( buffer, 1, BUF_SIZE, stdin );
        position = 0;
    }

    return buffer[ position++ ];
}

inline long long readInt()
{
    long long result = 0;
    char c;

    do
    {
        c = getChar();

    } while ( !isdigit( c ) );

    do
    {
        result = 10LL * result + c - '0';
        c = getChar();

    } while ( isdigit( c ) );

    return result;
}

int main()
{
    freopen("dtcsu.in", "r", stdin);
    freopen("dtcsu.out", "w", stdout);

    for ( int i = 1; i <= 276997; ++i )
    {
        long long nr = 0;

        nr = readInt();

        nr /= ( nr & ( -nr ) );

        S.insert( nr );
    }

    long long N, numb;
    int number = 0;

    N = readInt();

    for ( long long i = 1; i <= N; ++i )
    {
        numb = readInt();

        if ( numb )
        {
            numb /= ( numb & ( -numb ) );

            number += S.count( numb );
        }
    }

    printf("%d\n", number);

    return 0;
}