Cod sursa(job #1740073)

Utilizator PopoviciRobertPopovici Robert PopoviciRobert Data 10 august 2016 19:39:08
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <cstdio>
#include <cctype>
#include <vector>
#define MOD 666013
using namespace std;
vector <long long> H[MOD];
#define MAXBUF (1<<17)
char buf[MAXBUF];
int pos=MAXBUF;
FILE*fi,*fout;
inline char nextch(){
   if(pos==MAXBUF){
      fread(buf,1,MAXBUF,fi);
      pos=0;
   }
   return buf[pos++];
}
inline long long getnr(){
   char a=nextch();
   while(isdigit(a)==0)
     a=nextch();
   long long nr=0;
   while(isdigit(a)==1){
      nr=nr*10+a-'0';
      a=nextch();
   }
   return nr;
}
int main(){
   int i,q,rez,a,n;
   long long x;
   fi=fopen("dtcsu.in" ,"r");
   fout=fopen("dtcsu.out" ,"w");
   for(i=1;i<=276997;i++){
      x=getnr();
      if(x&1)
        H[x%MOD].push_back(x);
   }
   q=getnr();
   rez=0;
   while(q>0){
      q--;
      x=getnr();
      x/=(x&(-x));
      a=x%MOD;
      n=H[a].size();
      i=0;
      while(i<n&&H[a][i]!=x)
         i++;
      if(i<n)
        rez++;
   }
   fprintf(fout,"%d" ,rez);
   fclose(fi);
   fclose(fout);
   return 0;
}