Cod sursa(job #992916)
Utilizator | skyper skyper96 | Data | 2 septembrie 2013 19:06:43 |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.86 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
long long p,cont;
int i,n,ok,j,ok2;
f>>p;
if(p==1)
g<<"0";
if(p>1)
{
ok=0;
i=0;
while(ok==0&&i<=18)
{
n=1;
i++;
for(j=1;j<=i;++j)
{
n=n*j;
}
ok2=1;
cont=0;
while(ok2)
{
if(n%10!=0)
ok2=0;
if(n%10==0&&ok2==1)
{
cont++;
n=n/10;
}
}
if(cont==p)
ok=1;
}
if(ok==1)
g<<i;
if(ok==0)
g<<"-1";
}
return 0;
}