Pagini recente » Cod sursa (job #3278643) | Cod sursa (job #1849787) | Cod sursa (job #1476615) | Cod sursa (job #2898381) | Cod sursa (job #2626095)
#include <fstream>
#include<iostream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int numar(int x){
int nr=0,y=5;
while(x>=y)
{
nr+=x/y;
y*=5;
}
return nr;
}
int caut(int a,int b,int x){
int k;
int m;
int y=-1;
while (a <= b) {
m = (a + b) / 2;
k=numar(m);
if (k == x)
y=m;
if(k >= x)
b = m - 1;
else
a = m + 1;
}
if(y!=0)
return y;
return 1;
}
int main()
{
int n,k;
f>>n;
k=caut(0,2000000000,n);
g<<k;
return 0;
}