Mai intai trebuie sa te autentifici.
Cod sursa(job #119097)
Utilizator | Data | 29 decembrie 2007 14:57:35 | |
---|---|---|---|
Problema | Factorial | Scor | 75 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.7 kb |
#include <fstream>
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();
unsigned int nr_zerouri=0;
bool gasit=false;
for (unsigned int i=1; !gasit; 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) {
gasit = true;
f_out << "-1\n";
}
}
f_out.close();
return 0;
}