Pagini recente » Profil DanielG | Monitorul de evaluare | Monitorul de evaluare | Profil TheCreeep | Cod sursa (job #1036576)
#include<stdio.h>
#include<algorithm>
#include<cassert>
#define mod 100019
using namespace std;
FILE*f=fopen("dtcsu.in","r");
FILE*g=fopen("dtcsu.out","w");
int ch,sol;
const int n = 276997;
char buff[25];
long long H[mod+5];
int main () {
long long x = 0; int in = 0;
for ( int i = 1 ; i <= n ; ++i ){
fgets(buff,23,f);
x = 0;
ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
x = x*10 + buff[ch]-'0';
++ch;
}
if ( x % 11 == 0 ) continue ;
H[ x % mod ] = x;
}
int q = 0;
fgets(buff,23,f); ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
q = q*10 + buff[ch]-'0';
++ch;
}
for ( int i = 1 ; i <= q ; ++i ){
fgets(buff,23,f);
long long x = 0;
ch = 0;
while ( buff[ch] >= '0' && buff[ch] <= '9' ){
x = x*10 + buff[ch]-'0';
++ch;
}
if ( x == 0 ) continue ;
while ( x % 11 == 0 ) x /= 11;
if ( x == H[x % mod] ) ++sol;
}
fprintf(g,"%d\n",sol);
fclose(f);
fclose(g);
return 0;
}