Pagini recente » Cod sursa (job #1308141) | Cod sursa (job #572191) | Cod sursa (job #1688741) | Cod sursa (job #1069993) | Cod sursa (job #1044907)
#include<stdio.h>
int solutie(int n)
{
int x=1,sol=0;
while(x<=n)
{
x=x*5;
sol=sol+n/x;
}
return sol;
}
int main()
{
int a,m,x,y,p;
FILE *f=fopen("fact.in","r");
FILE *g=fopen("fact.out","w");
fscanf(f,"%d",&p);
if(p==0)
fprintf(g,"1");
else
{
x=5; y=500000000;
while(x<=y)
{
m=(x+y)/2;
if(solutie(x)==p)
{
a=x;
x=y+1;
}
if(solutie(y)==p)
{
a=y;
x=y+1;
}
if(solutie(m)<p)
x=m;
if(solutie(m)>p)
y=m;
if(solutie(m)==p)
{
a=m;
x=y+1;
}
}
while(a%5!=0)
a--;
fprintf(g,"%d",a);
}
}