Cod sursa(job #1032457)

Utilizator GheorgheMihaiMihai Gheorghe GheorgheMihai Data 15 noiembrie 2013 19:30:10
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.71 kb
#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;
}