Cod sursa(job #2177819)
| Utilizator | Data | 18 martie 2018 20:39:25 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <iostream>
#include <fstream>
using namespace std;
fstream f("fact.in");
fstream g("fact.out");
int P;
int fact(long long int f,long long int b,long long int x)
{
if(x==0)
return 0;
if(b>x)
return f;
f=f*b;
return fact(f,b+1,x);
}
int nr0lasf(long long int x,long long int nr)
{
if(x==0)
return 1;
if(x%10!=0)
return nr;
return nr0lasf(x/10,nr+1);
}
void cauta(long long int n)
{
if(nr0lasf(fact(1,1,n),0)==P)
{
g<<n;
return ;
}
cauta(n+1);
}
int main()
{
f>>P;
cauta(0);
return 0;
}
