Pagini recente » Cod sursa (job #1769366) | Istoria paginii runda/brasov_city_challenge/clasament | Cod sursa (job #1098019) | Cod sursa (job #403897) | Cod sursa (job #1856075)
#include <cstdio>
FILE *in,*out;
using namespace std;
const int L = 26;
int nrcifrezero(int x)
{
int putere = 5,r = 0;
if(x == 0)
return 0;
while(x != 0)
{
r += x/putere;
x /= 5;
}
return r;
}
int cauta(int x)
{
int pas,r = 0;
pas = 1 << L;
while(pas != 0)
{
if(nrcifrezero(r + pas) < x)
r += pas;
pas /= 2;
}
r ++;
if(nrcifrezero(r) != x)
return -1;
return r;
}
int main()
{
in = fopen("fact.in","r");
out = fopen("fact.out","w");
int p;
fscanf(in,"%d",&p);
if(p == 0)
fprintf(out,"1");
else
fprintf(out,"%d",cauta(p));
return 0;
}