Pagini recente » Cod sursa (job #3293954) | Cod sursa (job #3193858) | Cod sursa (job #82636) | Cod sursa (job #962408) | Cod sursa (job #1591847)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int main() {
long a;
in >> a;
if(a == 0) {
out << 1;
return 0;
}
if((a+1)%6 == 0) {
out << "-1";
return 0;
}
long dec = (a+1)/6;
out << a*5 - dec*5;
/*long long nr = 0;
long long sec = 0;
long fact2 = 0;
long fact5 = 0;
while(true) {
nr++;
sec = nr;
while(sec%2 == 0 && sec != 0) {
fact2++;
sec /= 2;
}
sec = nr;
while(sec%5 == 0 && sec != 0) {
fact5++;
sec /= 5;
}
if(min(fact2, fact5) == a) {
cout << nr;
break;
} else if(min(fact2, fact5) > a) {
cout << "-1";
break;
}
}*/
return 0;
}