Cod sursa(job #1030829)

Utilizator ioalexno1Alexandru Bunget ioalexno1 Data 15 noiembrie 2013 17:00:47
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda FMI No Stress 4 Marime 0.62 kb
#include <cstdio>
#include <cstdlib>

using namespace std;

FILE *f = fopen("dtcsu.in","r");
FILE *g = fopen("dtcsu.out","w");

long long x;

int main(){
    
    for( int i = 1; i <= 276997; ++i )
        fscanf(f,"%d ",&x);
    int q;
    fscanf(f, "%d", &q );
    int sol = 0;
    for(; q >= 1; --q ){
        
        fscanf(f, "%lld", &x);
        if ( x == 0 ) x = -1;
        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;
        if( x == 1 ) ++sol;        
    
    }
    fprintf(g, "%d", sol);
    return 0;
}