Pagini recente » Cod sursa (job #696421) | Cod sursa (job #2907154) | Cod sursa (job #2326894) | Cod sursa (job #272217) | Cod sursa (job #2645075)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int zero(int a)
{
int nr_zero = 0;
for(int i = 5; i<=a; i=i*5)
{
nr_zero = nr_zero + a/i;
}
return nr_zero;
}
int main()
{
int p,st=1,dr=100000,mij,sol = -1;
fin>>p;
if(p!=0){
while(st<=dr){
mij = (dr-st)/2+st;
if(zero(mij)==p){
sol = mij;
dr = mij - 1;
}
else{
if(zero(mij) > p){
dr = mij - 1;
}
else{
if(zero(mij)<p){
st = mij+1;
}
}
}
}
}
else{
fout<<0;
return 0;
}
fout<<sol;
return 0;
}