Cod sursa(job #597865)
| Utilizator | Data | 23 iunie 2011 16:16:32 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <stdio.h>
// nr natural minim pt care N! are P zerouri;
int main()
{
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
long int p, n = 0, n2, p2 = 0;
scanf("%ld", &p);
while(p > p2)
{
n = n + 5;
n2 = n;
while(n2 % 10 == 0 && n2 != 0)
{
n2 = n2 / 10;
p2++;
}
while(n2 % 5 == 0 && n2 != 0)
{
n2 = n2 / 5;
p2++;
}
if(p2 == p)
{
printf("%ld", n);
return 0;
}
}
printf("-1");
return 0;
}
