Cod sursa(job #2083748)
| Utilizator | Data | 8 decembrie 2017 08:33:40 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
long long l1,l2,p,m,c,fac,poz,i,ci;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
cin>>p;
l1=1;
l2=2000000000;
poz=1;
while(l1<=l2){
m=(l1+l2)/2;
c=0;
ci=5;
while(m/ci>=1)
{
c+=m/ci;
ci=ci*c;
}
if(c>p)
l2=m-1;
else
{
l1=m+1;
poz=m;
}
}
cout<<poz;
return 0;
}
