Cod sursa(job #2156540)
Utilizator | Data | 8 martie 2018 19:55:06 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long n,p,i,st,dr,mid,a,x;
int main(){
fin>>p;
st=1;
dr=1;
for(i=1;i<=p/i;i++){
dr*=10;
}
while(st<=dr){
mid=(st+dr)/2;
a=5;
x=0;
while(a<=mid){
x+=mid/a;
a*=5;
}
if(x<p)
st=mid+1;
else
dr=mid-1;
}
fout<<st;
return 0;
}