Cod sursa(job #1049496)

Utilizator thewildnathNathan Wildenberg thewildnath Data 7 decembrie 2013 13:29:44
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.07 kb
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;

#define MOD 10073

long long a;
char c[20];
vector <long long> v[MOD+2];

inline int find()
{
    int i,list=a%MOD;
    for(i=0;i<v[list].size();++i)
        if(v[list][i]==a)
            return 1;
    return 0;
}

inline void numar()
{
    int i=0,x;
    a=0;
    while(c[i]<'0'||c[i]>'9')
        ++i;
    while(c[i]>='0'&&c[i]<='9')
    {
        x=c[i]-'0';
        a=a*10+(long long)x;
        ++i;
    }
}

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    int n=276997,m,i,sol=0;

    for(i=1;i<=n;++i)
    {
        memset(c,0,sizeof(c));
        scanf("%s\n",&c);
        numar();

        if(a%2)
            v[a%MOD].push_back(a);
    }

    scanf("%d\n",&m);
    for(i=1;i<=m;++i)
    {
        memset(c,0,sizeof(c));
        scanf("%s\n",&c);
        numar();

        if(a)
        {
            a/=(a&(-a));
            sol+=find();
        }

    }

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

    return 0;
}