Pagini recente » Cod sursa (job #2990859) | Cod sursa (job #243277) | Cod sursa (job #529232) | Cod sursa (job #2040026) | Cod sursa (job #1856068)
#include <cstdio>
FILE *in,*out;
using namespace std;
const int L = 26;
int nrcifrezero(int x)
{
int putere = 5,r = 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);
fprintf(out,"%d",cauta(p));
return 0;
}