Cod sursa(job #2148743)
Utilizator | Carol Luca Carol_Luca | Data | 1 martie 2018 22:44:48 |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main()
{
int p,n=0,exp=0,aux;
in>>p;
if(p==0)
{
out<<1;
return 0;
}
while(p>exp)
{
n+=5;
aux=n;
while(aux%5==0)
{
aux/=5;
exp++;
}
}
if(p==exp)
{
out<<n;
return 0;
}
if(p<exp)
{
out<<-1;
return 0;
}
}