Cod sursa(job #2612428)
Utilizator | Data | 8 mai 2020 23:29:52 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
if (p==0)
fout<<"1";
else {
int nr=0,copie,putere5=0;
while(putere5 < p) {
nr+=5;
copie = nr;
while(copie%5 == 0) {
copie/=5;
putere5++;
}
}
if (putere5 > p) {
fout<<"-1";
}
else fout<<nr;
}
fin.close();
fout.close();
return 0;
}