Cod sursa(job #1595985)
| Utilizator | Data | 10 februarie 2016 17:57:27 | |
|---|---|---|---|
| Problema | Factorial | Scor | 40 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <cstdio>
using namespace std;
int main()
{
int p,rez=0,cop;
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
scanf("%d", &p);
if(p==0)
printf("%d", 1);
else
for(int i=5; i<=100000000; i+=5)
{
cop = i;
while(cop%5==0)
cop /= 5, rez++;
if(rez==p)
{
printf("%d", i);
return 0;
}
else if(rez>p)
{
printf("%d", -1);
return 0;
}
}
}