Cod sursa(job #1197978)
| Utilizator | Data | 14 iunie 2014 11:14:08 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
using namespace std;
int zero( int n )
{
int nr = 0;
while( n >= 5 )
{
nr += n/5;
n/=5;
}
return nr;
}
int cautare( int p )
{
int i = 0, pas;
pas = 1 << 30;
while( pas != 0 )
{
if ( zero(i+pas) < p )
i+=pas;
pas/=2;
}
return i;
}
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
int p, aux;
in >> p;
aux = cautare(p) + 1;
if ( zero(aux) == p )
out << aux;
else
out << -1;
return 0;
}
