Pagini recente » Profil PanainteTiberiu | Cod sursa (job #1477514) | Hello! | Infoarena Monthly 2014 - Runda 5 | Cod sursa (job #1032457)
#include <stdio.h>
#include <unordered_set>
using namespace std;
int n;
unordered_set <int> h;
int main ()
{
freopen ("dtcsu.in", "r", stdin);
freopen ("dtcsu.out", "w", stdout);
long long x = 0;
int i, j, sol = 0;
char s[22];
for (i = 1; i <= 276997; i ++)
{
gets (s + 1);
x = 0;
for (j = 1; '0' <= s[j] && s[j] <= '9'; j ++)
x = x * 10 + s[j] - '0';
if (x % 11 == 0)
continue;
else
h.insert (x);
}
scanf ("%d\n", &n);
while (n --)
{
gets (s + 1);
x = 0;
for (j = 1; '0' <= s[j] && s[j] <= '9'; j ++)
x = x * 10 + s[j] - '0';
while (x % 11 == 0)
x /= 11;
if (h.find (x) != h.end())
sol ++;
}
printf ("%d\n", sol);
return 0;
}