Cod sursa(job #1135225)

Utilizator dragangabrielDragan Andrei Gabriel dragangabriel Data 7 martie 2014 15:13:12
Problema Dtcsu Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define nmax 276997
using namespace std;
int n,i,j,k;
set<long long>s;
long long x;
char c[22];

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    for (i=1;i<=nmax;i++)
    {
        gets(c);
        x=0;
        char *p=c;
        while (*p>='0' && *p<='9') x=x*10+*p-'0',++p;
        if (x&1) s.insert(x);
    }
    scanf("%d\n",&n);
    for (i=1;i<=n;i++)
    {
        gets(c);
        x=0;
        char *p=c;
        while (*p>='0' && *p<='9') x=x*10+*p-'0',++p;
        if (x!=0)
        {
            x/=(x&(-x));
            if (s.find(x)!=s.end()) k++;
        }
    }
    printf("%d\n",k);
    return 0;
}