Cod sursa(job #1803677)
| Utilizator | Data | 11 noiembrie 2016 17:59:49 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <stdio.h>
#include <stdlib.h>
inline long long leg(int n){
long long nr=0LL;
long long p=5LL;
while(p<=n){
nr+=1LL*n/p;
p*=5LL;
}
return nr;
}
int main()
{
FILE*fin,*fout;
int p;
long long st,a;
fin=fopen("fact.in","r");
fout=fopen("fact.out","w");
fscanf(fin,"%d",&p);
fclose(fin);
a=0LL;st=(1LL<<35);
while(st>0LL){
if (leg(st+a)<p)
a+=st;
st>>=1LL;
}
fprintf(fout,"%lld\n",a+1LL);
fclose(fout);
return 0;
}
