Cod sursa(job #675255)
| Utilizator | Data | 7 februarie 2012 14:40:55 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main ()
{
unsigned long long p,n,aux,nr,i,fact=0;
fin>>p;
n=0;
for (i=5;fact<p;i+=5)
{
aux=i;
n=i/5;
fact++;
while (n%5==0)
{
fact=fact+1;
n=n/5;
}
}
if (fact==p)
fout<<i-5;
else
fout<<-1;
fin.close ();
fout.close ();
return 0;
}
