Pagini recente » Cod sursa (job #2192022) | **** | Cod sursa (job #703050) | Cod sursa (job #1773580) | Cod sursa (job #1610866)
#include <iostream>
#include <cstdio>
using namespace std;
FILE *f,*g;
int x,p;
int zero(int n)
{
int nr = 0;
while (n >= 5)
{
nr += n / 5;
n /= 5;
}
return nr;
}
int cautzero(int p)
{
//caut cel mai mare n cu propr ca zero(n) < p -> returnez 1 + n
int i=0,pas = 1 << 30;
while(pas != 0)
{
if (zero(i+pas) < p)
i += pas;
pas /= 2;
}
return 1 + i;
}
int main()
{
f=fopen("fact.in","r");
g=fopen("fact.out","w");
fscanf(f,"%d",&p);
x=cautzero(p);
//if(p)
fprintf(g,"%d",x);
//else fprintf(g,"1");
fclose(f);
fclose(g);
return 0;
}