Pagini recente » Cod sursa (job #2543861) | Cod sursa (job #574981) | Borderou de evaluare (job #1773443) | Cod sursa (job #683961) | Cod sursa (job #2614706)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int P;
int count0(int n){
int rez = 0;
for(int k = 5; k <= n; k *= 5){
rez += n / k;
}
return rez;
}
int main(){
f>>P;
int i = 1, j = 1000000000;
while(i < j){
int m = i + (j - i) / 2;
if(count0(m) < P){
i = m + 1;
}
else{
j = m;
}
}
if(count0(j) == P){
g<<j;
}
else
g<<"-1";
return 0;
}