Cod sursa(job #595820)
Utilizator | Data | 14 iunie 2011 14:25:44 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int zero(int x)
{
int s=0;
while(x>=5)
{
s+=x/5;
x/=5;
}
return s;
}
int caut(int x)
{
int i,pas=(1<<30);
for(i=0;pas!=0;pas>>=1)
if(zero(i+pas)<x) i+=pas;
return i+1;
}
int main()
{
int p,n;
f>>p;
n=caut(p);
if(zero(caut(p))==p) g<<caut(p);
else g<<"-1";
g<<"\n";
}