Cod sursa(job #2138877)
| Utilizator | Data | 21 februarie 2018 22:31:34 | |
|---|---|---|---|
| Problema | Pairs | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
using namespace std;
ifstream cin("pairs.in");
ofstream cout("pairs.out");
const int nmax=1000000;
int n;
bool ap[nmax+5],viz[nmax+5];
long long ans=0;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
int key;
cin>>key;
ap[key]++;
}
for(int i=1;i<=nmax;i++)
{
if(viz[i]==0)
for(int j=i;j<=nmax;j+=i)
{
viz[j]=1;
ans+=ap[j];
}
}
cout<<ans;
return 0;
}
/**
**/
