Cod sursa(job #825239)
Utilizator | Data | 27 noiembrie 2012 22:24:52 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int n,p,i,j,x,ok;
fin>>p;
ok=1;
for(n=1;n<=INT_MAX;n++)
{
x=1;
for(i=1;i<=n;i++)
x=x*i;
j=0;
while(x&&j<p)
{
if(x%10==0)
{
j++;
x=x/10;
}
}
if(p==j)
{
fout<<n;
ok=0;
}
if(ok==1)fout<<"-1";
}
return 0;
}