Pagini recente » Cod sursa (job #1270592) | Cod sursa (job #3256267) | Cod sursa (job #2957817) | Cod sursa (job #928934) | Cod sursa (job #2618094)
#include <iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n;
int nz(int n)
{
int x=0;
while(n>=5)
{
n/=5;
x+=n;
}
return x;
}
int cbin(int x, int y){
if(x>y)
return -1;
int m=(y-x)/2+x;
int z=nz(m);
if(z==n)
return m;
if(z>n)
return cbin(x, m-1);
return cbin(m+1, y);
}
int main()
{
f>>n;
if(n==0)
g<<1;
else
{
int x = cbin(5, n*5);
x-=x%5;
g<<x;
}
return 0;
}