Cod sursa(job #1031476)

Utilizator mads2194FMI - Andrei Stroe mads2194 Data 15 noiembrie 2013 17:59:00
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.99 kb
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define WTF 276997

int res=0;

char text[277000][20];

void run()
{

}

bool fc(char c)
{
    int x = c - '0';
    if(x%2==0) return 1;
    if(x==5) return 1;
    return 0;
}

bool fc2(char a,char b)
{
    int x = a - '0';
    int y = b - '0';

    if((x*10+y)%3==0) return 1;
    return 0;
}

bool fc3(char *s,size_t l)
{
    for(size_t i=0;i<WTF;++i)
        if(strcmp(s,text[i])==0) return 1;
    return 0;
}

int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);

    //int n=WTF;

    for(size_t i=0;i<WTF;++i)
        gets(text[i]);

    int n;
    char s[20];
    scanf("%d",&n);
    while(n--)
    {
        gets(s);
        size_t l = strlen(s);
        if( fc( s[l-1]) ) ++res;
        else if( fc2( s[l-2],s[l-1]) ) ++res;
        else if( fc3(s,l) ) ++res;
    }

    printf("%d",res);

    return 0;
}