Cod sursa(job #854795)
Utilizator | Data | 14 ianuarie 2013 04:04:36 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 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;
while(k%5==0)
{k=k/5;
p++;
}
j++;
}
if(p==n)
g<<z;
else
g<<-1;
return 0;
}