Cod sursa(job #2051745)
| Utilizator | Data | 29 octombrie 2017 14:59:35 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.67 kb |
#include <fstream>
using namespace std;
ifstream cin ("fact.in") ;
ofstream cout ("fact.out") ;
int p ( int a )
{
int nr = 0 ;
while ( a % 5 == 0 )
{
nr ++ ;
a /= 5 ;
}
return nr ;
}
int main()
{
int P ;
cin >> P ;
int val = 0 ;
int i = 5 ;
if ( P == 0 )
{
cout << 1 ;
return 0 ;
}
while ( 1 )
{
val += p ( i ) ;
if ( val == P )
{
cout << i ;
return 0 ;
}
else if ( val > P )
{
cout << -1 ;
return 0 ;
}
i += 5 ;
}
return 0;
}
