Pagini recente » Cod sursa (job #1619282) | Cod sursa (job #1694793) | Cod sursa (job #879594) | Cod sursa (job #2807258) | Cod sursa (job #2443954)
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
int n,i,j,k=0,d,t;
ifstream f("economie.in");
ofstream g("economie.out");
f>>n;
int v[n+1],w[n+1];
for(i=1;i<=n;i++)
f>>v[i];
sort(v+1,v+n+1);
w[++k]=v[1];
for(i=1;i<=k;i++)
for(j=i+1;j<=n;j++){
t=0;
for(d=1;d<=k;d++)
if(v[j]%w[d]==0)
t=1;
if(t==0)
w[++k]=v[j];}
g<<k<<'\n';
for(i=1;i<=k;i++)
g<<w[i];
}