Cod sursa(job #2093865)
Utilizator | Paul Orasan PaulOrasan | Data | 24 decembrie 2017 16:05:10 |
---|---|---|---|
Problema | Factorial | Scor | 45 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <cstdio>
using namespace std;
FILE * fin=fopen("fact.in","r");
FILE * fout=fopen("fact.out","w");
int getAparitii(int n)
{
int ct=0;
while (n%5==0){
ct++;
n/=5;
}
return ct;
}
int f(long long int n)
{
if (n/5==0)
return 0;
else return n/5+f(n/5);
}
int main()
{
int p;
long long int n;
fscanf(fin,"%d",&p);
long long int a,b,c,x;
a=1;
b=100000000;
c=(a+b)/2;
x=f(c);
while (x!=p){
if (x>p)
b=c-1;
else
a=c+1;
c=(a+b)/2;
x=f(c);
}
/* while (f(c-1)==p)
c--;*/
fprintf(fout,"%d",c-c%5);
}