Cod sursa(job #2083674)
| Utilizator | Data | 7 decembrie 2017 23:03:23 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.61 kb |
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int l1,l2,p,m,c,fac,poz,i,ci;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
cin>>p;
l1=1;
l2=100000001;
while(l1<=l2){
m=(l1+l2)/2;
c=0;
for(i=5;i<=m;i+=5){
ci=i;
while(ci!=0&&ci%5==0){
ci=ci/5;
c++;
}
}
if(c<p)
l1=m+1;
if(c>p)
l2=m-1;
if(c==p){
poz=m;
l2=m-1;
}
}
cout<<poz;
return 0;
}
