Cod sursa(job #939842)
| Utilizator | Data | 14 aprilie 2013 22:33:11 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.65 kb |
#include <fstream>
using namespace std;
int p,n,l,r;
int cautare_binara()
{
if (p==0)
return 1;
while (l<=r)
{
int m;
int mm;
mm=(l+r)/2;
n=0;
m=mm;
while(m!=0)
{
n+=m/5;
m/=5;
}
if (n==p)
return mm-mm%5;
else if (n<p)
l=mm+1;
else
r=mm-1;
}
return -1;
}
int main()
{
ifstream f1("fact.in");
ofstream f2("fact.out");
f1>>p;
l=0;
r=2000000000;
f2<<cautare_binara();
f1.close();
f2.close();
return 0;
}
