Pagini recente » Cod sursa (job #981764) | Cod sursa (job #1361034) | Cod sursa (job #2297659) | Cod sursa (job #2836047) | Cod sursa (job #1563598)
#include <fstream>
using namespace std;
ifstream cin ( "fact.in" ) ;
ofstream cout ( "fact.out" ) ;
long long nrzero ( int n )
{
long long put = 5 ;
int sol = 0 ;
while ( put < n )
{
sol += ( int ) n / put ;
put *= 5 ;
}
return sol ;
}
int main()
{
int p ;
cin >> p ;
int st = 1 ;
int dr = 1e9 ;
int gasit = -1 ;
while ( st <= dr )
{
int mij = ( st + dr ) / 2 ;
if ( nrzero ( mij ) < p )
{
st = mij + 1 ;
}
else {
dr = mij - 1 ;
gasit = mij ;
}
}
if ( gasit == -1 ) {
cout << -1 ;
}
else {
if ( gasit >= 5 )
cout << gasit - gasit % 5 ;
else cout << 1 ;
}
return 0;
}