Cod sursa(job #670189)
| Utilizator | Data | 28 ianuarie 2012 16:59:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<stdio.h>
using namespace std;
int cont;
int nrdiv(int x)
{
while((x!=1) && (x%5==0))
{
x=x/5;
cont++;
}
}
int main()
{
int p,i,z;
z=-1;
i=0;
cont=0;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(p<0)
printf("%d",z);
else if(p==0)
printf("1");
else
{
while(cont!=p)
{
i=i+5;
nrdiv(i);
}
printf("%d",i);
}
fclose(stdin);
fclose(stdout);
return 0;
}
