Cod sursa(job #333216)
Utilizator | Data | 21 iulie 2009 18:30:49 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int n)
{
int r=0;
while(n)
{
r+=n/5;
n/=5;
}
return r;
}
int caut(int x)
{
int st=1,dr=1<<30,mij;
while(st!=dr)
{
mij=(st+dr)/2;
if(zero(mij)>=x)
dr=mij;
else st=mij+1;
}
if(zero(st)==x)
return st;
return -1;
}
int main()
{
int p;
in>>p;
out<<caut(p)<<"\n";
in.close();
out.close();
}