Cod sursa(job #2661858)
Utilizator | Data | 22 octombrie 2020 20:04:06 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int nrzerouri(int n){
int nr=0;
while(n>=5){
nr+=n/5;
n/=5;
}
return nr;
}
const int L=28;
int main()
{
int n,r,pas;
pas=1 << L;
in>>n;
r=0;
while(pas!=0){
if(nrzerouri(r+pas)<n){
r+=pas;
}
pas/=2;
}
r++;
if(nrzerouri(r)==n)
out<<r;
else
out<<"-1";
return 0;
}