Cod sursa(job #2469077)
| Utilizator | Data | 6 octombrie 2019 14:58:59 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int n,li=1,lf=500000000,m,r,no=0,a=-1,p;
fin>>n;
while(li<=lf)
{
no=0;
m=(li+lf)/2;
for(r=5;r<=m;r*=5){no+=m/r;}
if(no==n)
{a=m;
lf=m-1;}
if(no>n)
lf=m-1;
if(no<n)
li=m+1;
}
fout<<a;
return 0;
}
