Cod sursa(job #370521)
Utilizator | Data | 1 decembrie 2009 15:01:44 | |
---|---|---|---|
Problema | Factorial | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<fstream.h>
long m,a,exp,p,r,l;
long fact(long x)
{
long b=5,exp=0;
while(x>=b)
{
exp+=x/b;
b*=5;
}
return exp;
}
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
a=1;exp=0;
while(exp<p)
{
a<<=1;
exp=fact(a);
}
a-=5;
while(fact(a)>p)a-=5;
g<<a-(a%5);
return 0;
}