Pagini recente » Cod sursa (job #682047) | Cod sursa (job #1573401) | Calibrare limite de timp | Cod sursa (job #914156) | Cod sursa (job #2427982)
#include <iostream>
#include <fstream>
using namespace std;
const int VMAX=500000000;
int nr_zero(int n){
int nr=0;
while(n>0)
{
nr+=n/5;
n/=5;
}
return nr;
}
int main()
{
fstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin >> p;
int st=1;
int dr=VMAX;
while(st<dr)
{
int m=(st+dr)/2;
if(nr_zero(m)>=p)
{
dr=m;
}
else
{
st=m+1;
}
}
if (nr_zero(st) != p)
{
st = -1;
}
fout<<st;
fin.close();
fout.close();
return 0;
}