Pagini recente » Cod sursa (job #2031868) | Cod sursa (job #1995546) | Cod sursa (job #1841854) | Cod sursa (job #1616476) | Cod sursa (job #312150)
Cod sursa(job #312150)
#include<fstream.h>
fstream f("fact.in",ios::in);
fstream g("fact.out",ios::out);
void main(){
unsigned long p,n,n2,n5;
f>>p;
n2=0;
n5=0;
int gasit,exista;
unsigned long c=1,aux;
gasit=0;
while(gasit==0)
{ c++;
aux=c;
while(aux%2==0)
{
n2++;
aux/=2;
}
while(aux%5==0)
{
n5++;
aux/=5;
}
if(n2>p&&n5>p)
{exista=0;
gasit=1;
}
else
if(n2==p&&n5>p || n2>p&&n5==p)
{
gasit=1;
} exista=1;
}
if(exista)
g<<c;
else
g<<-1;
g.close();
}