Pagini recente » Cod sursa (job #3123913) | Cod sursa (job #2277594) | Cod sursa (job #1534752) | Cod sursa (job #2456809) | Cod sursa (job #2618095)
#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;
if(x==0)
x--;
g<<x;
}
return 0;
}