Cod sursa(job #854796)
Utilizator | Data | 14 ianuarie 2013 04:06:23 | |
---|---|---|---|
Problema | Factorial | Scor | 55 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n,k,j,z;
long long p;
int main()
{
f>>n;
p=0;
j=1;
z=5;
if(n==0)
{
g<<1;
return 0;
}
while ( p<=n-1 )
{
p++;
z=5;
z=z*j;
k=j;
if(k%5==0)
while(k%5==0)
{k=k/5;
p++;
}
j++;
}
if(p==n)
g<<z;
else
g<<-1;
return 0;
}