Cod sursa(job #397748)
Utilizator | Data | 17 februarie 2010 13:37:03 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<fstream>
using namespace std;
int zero(int n)
{
int rez=0;
while (n)
{
rez+=n/5;
n/=5;
}
return rez;
}
int caut(int p)
{
int i,pas=1<<30;
for (i=0;pas;pas>>=1)
if (zero(i+pas)<p) i+=pas;
return i+1;
}
int main()
{
int p;
ifstream f("fact.in");
ofstream o("fact.out");
f>>p;
int z=caut(p);
if (zero(z)!=p) z=-1;
o<<z;
return 0;
}