Cod sursa(job #2822175)
| Utilizator | Data | 23 decembrie 2021 17:56:22 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
using namespace std;
int n,P;
int zero(int x){
int Nrz=0,put=1;
while (put<=x){
put*=5;
Nrz+=(x/put);
}
return Nrz;
}
int caut(int st, int dr){
int a=-1,zr;
while (st<=dr){
int mij=(st+dr)/2;
zr=zero(mij);
if (zr==P){
a=mij;
dr=mij-1;
}
else if (zr>P) dr=mij-1;
else if (zr<P) st=mij+1;
}
return a;
}
int main()
{
cin>>P;
cout<<caut(1, 100000000);
}
