Cod sursa(job #1191424)

Utilizator DenisacheDenis Ehorovici Denisache Data 27 mai 2014 16:41:33
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <cstdio>
#include <cstring>
#include <set>
using namespace std;
#define NMAX 276997
long long N;
int Q,nr;
set <long long> S;
char cmd[22];
int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    for (register int i=1;i<=NMAX;i++)
    {
        gets(cmd); N=0;
        char *p=cmd;
        while (*p>='0' && *p<='9') N=N*10+*p-48,++p;
        S.insert(N);
    }
    scanf("%d",&Q);
    for (register int i=1;i<=Q;i++)
    {
        gets(cmd); N=0;
        char *p=cmd;
        while (*p>='0' && *p<='9') N=N*10+*p-48,++p;
        if (N!=0)
        {
            N/=(N&-N);
            if (S.find(N)!=S.end()) ++nr;
        }
    }
    printf("%d",nr);
    return 0;
}