Cod sursa(job #1915507)

Utilizator ionanghelinaIonut Anghelina ionanghelina Data 8 martie 2017 21:20:47
Problema Dtcsu Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.01 kb
#include<bits/stdc++.h>
#define dim 100000
using namespace std;
long long n,x,sol,q;
int poz=0;
char buff[dim+5];
void read(long long &nr)
{
    nr=0LL;
    while(buff[poz]<'0' || buff[poz]>'9')
    {
        poz++;
        if(poz==dim)
        {
            poz=0;
            fread(buff,1,dim,stdin);
        }
    }
    while(buff[poz]>='0' && buff[poz]<='9')
    {
        nr=nr*10+(buff[poz]-'0');
        poz++;
        if(poz==dim)
        {
            poz=0;
            fread(buff,1,dim,stdin);
        }
    }
}
int main()
{
    freopen("dtcsu.in","r",stdin);
    freopen("dtcsu.out","w",stdout);
    fread(buff,1,dim,stdin);
    for(int i=1;i<=276997;i++)
    {
        read(x);
    }
    read(q);
    for(int i=1;i<=q;i++)
    {
        read(x);
        while(!(x%2)) x>>=1;
        while(!(x%3)) x/=3;
        while(!(x%5)) x/=5;
        while(!(x%7)) x/=7;
        while(!(x%11)) x/=11;
        if(x==1LL) sol=sol+1LL;
    }
    printf("%lld\n",sol);
    return 0;
}