Pagini recente » Cod sursa (job #1350397) | Cod sursa (job #1768949) | Cod sursa (job #1482679) | Cod sursa (job #100853) | Cod sursa (job #1934046)
#include <iostream>
#include <cstdio>
using namespace std;
FILE*fin=fopen("fact.in","r");
FILE*fout=fopen("fact.out","w");
int main()
{
int n , p , k = 0 , x , i , k1 = 0 , j ;
cin >> p ;
for ( i = 1 ; i <= p * 5 ; ++i )
{
if ( i % 5 == 0 )
{
x = i ;
if ( ( i / 5 ) % 5 == 0 )
{
while ( x % 5 == 0 )
{
++k ;
x /= 5 ;
}
}
else ++k ;
if ( k >= p ) break ;
}
}
n = i ;
for ( j = 5 ; j <= n ; ++j )
{
if ( j % 5 == 0 )
{
x = j ;
if ( ( j / 5 ) % 5 == 0 )
{
while ( x % 5 == 0)
{
++k1 ;
x /= 5 ;
}
}
else ++k1 ;
}
}
if ( k1 == p ) cout << i ;
else cout << "-1" ;
return 0;
}