Răspuns :
Răspuns:
#include <fstream>
using namespace std;
int main()
{int nr,nfmax=0,nrd,p,pp,fact,nrmax,pmax;
ifstream f("echilibrat.in");
ofstream g("echilibrat.out");
while(f>>nr)
{int nf=0,aux=nr;
fact=2;
int ok=0,fan=1;
while(nr>1&&fan==1)
{
if(nr%fact==0)
{ p=0;
while(nr%fact==0)
{
p++;
nr=nr/fact;
}
nf++;
if(ok==0)
pp=p;
else
if(pp!=p)
fan=0;
if(nf>=1)
ok=1;
}
fact++;
}
if(p==pp)
{if(nfmax<nf)
{nfmax=nf;
nrmax=aux;
pmax=pp;
}
if(nfmax==nf)
if(pmax<pp)
{pmax=pp;
nrmax=aux;}
if(nfmax==nf&&pmax==pp)
{
nrmax=aux;
}
}}
g<<nrmax<<" "<<nfmax<<" "<<pmax;
}
Explicație: