Cod sursa(job #368884)
Utilizator | deaconu ioan crysys | Data | 26 noiembrie 2009 12:56:29 |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<fstream.h>
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
long long p,n,min,j,a,b;
f>>p;
int gasit=0;
n=0;
a=b=0;
if(p==5)
g<<"-1";
else
if(p==0)
g<<"1";
else
while(gasit==0)
{
n=n+5;
/*j=n;
while(j%2==0)
{
j=j/2;
a++;
} */
j=n;
while(j%5==0 && j!=0)
{
j=j/5;
b++;
}
/* if(a>b)
min=b;
else */
min=b;
if(min==p)
{
gasit=1;
g<<n;
}
}
return 0;
}