Cod sursa(job #1518663)
Utilizator | Data | 6 noiembrie 2015 08:31:11 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
#include <iostream>
using namespace std;
int p,i,j=0,k;
void solutie()
{
if ( ( k % 5 == 0) && (k) )
{
j++;
k/=5;
solutie();
}
}
int main()
{
ifstream f1("fact.in");
ofstream f2("fact.out");
f1>>p;
if(p==0)
f2<<1;
else
{
for(i=5;j<p;i=i+5)
{
j++;
k=i/5;
solutie();
}
}
i -= 5;
if(j>p)
f2<<"-1";
else
f2<<i;
return 0;
}