Cod sursa(job #1476766)
Utilizator | Data | 25 august 2015 13:12:04 | |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<stdio.h>
int zerouri(int x)
{
int z=0;
while(x)
{
z+=x/5;
x/=5;
}
return z;
}
int main()
{
FILE* f1,*f2;
f1=fopen("prim.in","r");
f2=fopen("prim.out","w");
int p;
fscanf(f1,"%d",&p);
int st=1,dr=100000000000;
while(st<=dr)
{
int m=(st+dr)/2;
if(zerouri(m)<p)
st=m+1;
else dr=m-1;
}
if(zerouri(st)==p)
fprintf(f2,"%d\n",st);
else fprintf(f2,"-1\n");
fcloseall();
return 0;
}