Pagini recente » Cod sursa (job #3259807) | Cod sursa (job #280885) | Istoria paginii runda/shumenichb2013/clasament | Cod sursa (job #3161681) | Cod sursa (job #3185803)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
const int fmax= 500000000;
const int pmax= 268435456;
int five( int x ) {
int sol= 0;
for ( int i= 5; i<=x; i*= 5 ) {
sol+= x/i;
}
return sol;
}
int main() {
int n;
fin>>n;
int sol= pmax;
for ( int step= pmax; step>0; step>>= 1 ) {
if ( sol>step && five(sol-step)>=n ) {
sol-= step;
}
}
if ( five(sol)!=n ) {
sol= -1;
}
fout<<sol<<"\n";
return 0;
}