Cod sursa(job #1705988)
Utilizator | Data | 21 mai 2016 11:36:33 | |
---|---|---|---|
Problema | Factorial | Scor | 35 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
ofstream fout("fact.out");
ifstream fin("fact.in");
int p;
long long nr0;
int main()
{
fin>>p;
if( p == 0)
{
fout<<1;
return 0;
}
int nr = 5;
while( 1 )
{
int aux = nr;
while( aux % 5 == 0 )
{
aux /=5;
nr0++;
}
if(nr0 == p)
{
fout<<nr;
return 0;
}
else if( nr0 > p)
{
fout<<-1;
return 0;
}
nr += 5;
}
}