Cod sursa(job #2443985)
Utilizator | Data | 29 iulie 2019 22:39:00 | |
---|---|---|---|
Problema | Economie | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#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(j=2;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]<<'\n';
}