Pagini recente » Cod sursa (job #1157127) | Cod sursa (job #3275674) | Borderou de evaluare (job #3193485) | Cod sursa (job #2755081) | Cod sursa (job #586378)
Cod sursa(job #586378)
#include <cstdio>
void getprims(int x, int &_count2, int &_count5){
_count2 = _count5 = 0;
//check 2
while (x && !(x & 1)){
x >>= 1;
++_count2;
}
while (x % 5 == 0){
x /= 5;
++_count5;
}
}
int main(){
freopen("fact.in", "r", stdin);
freopen("fact.out", "w", stdout);
int P;
scanf("%d", &P);
int i = 0, count0 = 0, count2 = 0, count5 = 0;
int _count2, _count5;
while (count0 < P){
++i;
getprims(i, _count2, _count5);
count2 += _count2;
count5 += _count5;
count0 = count2 < count5? count2 : count5;
}
if (count0 == P) printf("%d", i);
else printf("-1");
return 0;
}