Cod sursa(job #1667311)
| Utilizator | Data | 28 martie 2016 20:41:30 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
long verificare(int n)
{
long nr_zero;
nr_zero=0;
while(n/5)
{
nr_zero+=n/5;
n/=5;
}
return nr_zero;
}
long p;
int main()
{
long mij,li=0,ls=32000;
bool gasit;
in>>p;
while((li<=ls)&&(!gasit))
{
mij=(li+ls)/2;
if(verificare(mij)==p&&verificare(mij-1)<p)
{
out<<mij;
gasit=1;
}
else
if(verificare(mij)<p)
li=mij+1;
else ls=mij-1;
}
if(gasit==0)
out<<mij;
return 0;
}
