Cod sursa(job #119090)
#include <fstream>
const unsigned int NUM_MAX_SIZE = 500;
struct Numar {
char n[NUM_MAX_SIZE];
unsigned int nr_size;
void Set(unsigned long);
};
using namespace std;
int main (void)
{
ifstream f_in("fact.in");
ofstream f_out("fact.out");
unsigned long P;
f_in>>P;
f_in.close();
//Numar nr;
unsigned int nr_zerouri=0;
bool gasit=false, imposib=false;
for (unsigned int i=1; !gasit && !imposib; i++) {
if (i%5==0) {
unsigned int w=i;
while (w%5 == 0) { w/=5; nr_zerouri++; }
}
nr_zerouri++;
if (nr_zerouri == P) {
gasit = true;
f_out << ((unsigned long long)i)*5 << '\n';
} else if (nr_zerouri > P) {
imposib = true;
f_out << "-1\n";
}
}
f_out.close();
}