Pagini recente » Cod sursa (job #1792621) | Cod sursa (job #2106482) | Cod sursa (job #1137590) | Cod sursa (job #2914476) | Cod sursa (job #2914497)
#include <fstream>
using namespace std;
int find(int p) {
int i = 0;
int aux = 0;
if (p == 0)
return 1;
while (p > 0) {
i = i + 5;
aux = i;
if (aux % 25 == 0){
do {
p = p - 2;
aux = aux / 25;
} while (aux % 25 == 0);
} else p--;
}
if (p < 0)
return -1;
return i;
}
int main() {
ifstream fin("fact.in");
ofstream fout("fact.out");
int p;
fin>>p;
int n = find(p);
fout<<n;
return 0;
}