Cod sursa(job #369856)
| Utilizator | Data | 29 noiembrie 2009 17:44:02 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int a ;
std::cin>>a;
int i = 1, g;
g = 0;
while (g < a)
{
if (i != 0 && i % 25 == 0)
{
g = g + 2;
goto label;
}
if (i != 0 && i % 125 == 0)
{
g = g + 3;
goto label;
}
if (i % 5 == 0)
g = g + 1;
label:
if (g + 1 == a)
a--;
else
i++;
}
if ((i-1) % 5 != 0)
std::cout<<"-1";
else
std::cout<<i-1;
return 0;
}