Cod sursa(job #1612710)
Utilizator | Data | 24 februarie 2016 23:28:49 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int n, x=0;
fin >> n;
if(n==0)
{
fout << "1";
return 0;
}
int i;
for(i=0; i<n;)
{
x+=5;
int aux=x;
while(aux%5==0 && aux!=0)
{
i++;
aux=aux/5;
}
}
if(i>n)
{
fout << "-1";
return 0;
}
fout << x;
return 0;
}