Pagini recente » Cod sursa (job #2416541) | Cod sursa (job #2658321) | Cod sursa (job #1164346) | Cod sursa (job #1789047) | Cod sursa (job #1981108)
#include <fstream>
#include <cmath>
using namespace std ;
ifstream cin ("fact.in") ;
ofstream cout ("fact.out") ;
long long zeros (int n)
{
long long S = 0 ;
while (n / 5) {
S = S + n / 5 ;
n /= 5 ;
}
return S ;
}
int main(int argc, char const *argv[])
{
int p ;
cin >> p ;
int valmax = (p + 1) * 5 ;
int bucket = (int)sqrt((double)valmax) ;
for (int i = 1 ; i <= valmax ; i += bucket) {
if (zeros (i) >= p) {
// cout << "pentru " << i << " " << zeros (i) << '\n' ;
for (int j = max (i - bucket, 1) ; j <= i ; ++ j) {
if (zeros (j) == p) {
cout << j ;
return 0 ;
}
}
break ;
}
}
cout << -1 ;
return 0;
}