Cod sursa(job #1040715)
Utilizator | Data | 24 noiembrie 2013 20:38:20 | |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long p, n, k, x;
int main()
{
fin>>p;
if (p==0) n=1;
else{
k=1;n=5;
while (k<p)
{ n=n+5;
x=n;
while(x%25==0)
{k=k+2;
x=x/25;
}
while(x%5==0)
{k=k+1;
x=x/5;
}
}}
if (k==p)
fout<<n;
else
fout<<-1;
return 0;
}