Cod sursa(job #1032394)

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

const int NR = 276997 ;

#define maxs 20

int Q ;

char sir[maxs] ;

bool ok(long long X)
{
    while( X % 2 == 0 )
        X /= 2 ;

    while( X % 3 == 0 )
        X /= 3 ;

    while( X % 5 == 0 )
        X /= 5 ;

    while( X % 7 == 0 )
        X /= 7 ;

    while( X % 11 == 0 )
        X /= 11 ;

    return ( X == 1 ) ;
}

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

    scanf("%d", &Q);

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

    scanf("%d\n", &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 ;
}