Pagini recente » Profil RinciogMatei | Cod sursa (job #1253340) | Cod sursa (job #1443556) | Profil SpirleaDavidCristian | Cod sursa (job #1253353)
#include <fstream>
using namespace std;
fstream in ("fact.in" , ios::in ),
out("fact.out", ios::out);
long long p;
long long zero(long long x);
int main(){
in >> p;
long long pas = 1LL<<32LL, i=0;
while( pas ){
if( zero( pas+i ) < p ){
i+=pas;
}
pas/=2LL;
}
if( zero( i+1LL ) == p )
out << i+1LL <<'\n';
else
out << "-1";
return 0;
}
long long zero(long long x){
long long rez = 0;
while( x>=5LL ){
rez += x/5LL;
x /= 5LL;
}
return rez;
}