Mai intai trebuie sa te autentifici.
Cod sursa(job #176649)
| Utilizator | Data | 11 aprilie 2008 15:34:42 | |
|---|---|---|---|
| Problema | Factorial | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.7 kb |
//fact INFOARENA
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long nrcifre(unsigned long long a){
long long cifre=0;
while (a>0)
{
cifre+=a/5;
a/=5;
}
return cifre;
}
unsigned long long cautare(long long p)
{
unsigned long long c,n=0,st,sf,mij;
st=1;
sf=n=1<<31;
while (st<sf)
{ mij=(st+sf)/2;
if (nrcifre(mij)>=p){
if (mij<n) n=mij;
sf=mij;
} else
{
st=mij+1;
}
}
return n;
}
int main()
{
long long p;
fin>>p;
fout<<cautare(p);
fout.close();
return 0;
}
