Cod sursa(job #451678)
| Utilizator | Data | 9 mai 2010 20:36:58 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<fstream>
using namespace std;
int f5(int a)
{
int x=a, f=0;
while(x!=0)
{
if (x%5==0)
{
f++;
x=x/5;
}
else
break;
}
return f;
}
int main()
{
ifstream in("factorial.in");
ofstream out("factorial.out");
int p,n=0,c=0;
in>>p;
while(c<=p)
{
c=c+f5(n);
n=n+5;
}
if(p<0)
out<<-1;
else if(p==0)
out<<1;
else
out<<n;
return 0;
}