Cod sursa(job #1031499)

Utilizator matei_cChristescu Matei matei_c Data 15 noiembrie 2013 18:00:08
Problema Dtcsu Scor 0
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.88 kb
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std ;

const int NR = 276997 ;

#define maxs 20

int Q ;

char sir[maxs] ;

bool ok(int X)
{
    for(int i = 13; i * i < X; ++i )
        if( X % i == 0 && i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0 && i % 11 != 0 )
            return false ;

    return true ;
}

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

    for(int i = 1; i <= NR; ++i )
        scanf("%s\n", sir);

    scanf("%d", &Q);

    int sol = 0 ;

    for(int i = 1; i <= Q; ++i )
    {
        scanf("%s\n", sir);

        int len = strlen(sir) ;
        long long qq = 0 ;

        for(int j = 0; j < len; ++j )
            qq = qq * 10 + ( sir[j] - '0' ) ;

        if( ok(qq) == true )
            ++sol ;
    }

    printf("%d", sol);

    return 0 ;
}