Cod sursa(job #2292803)
| Utilizator | Data | 29 noiembrie 2018 23:44:04 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out ("fact.out");
const int L=30;
int p;
int zero (int y)
{
int n=0;
while(y>=5)
{
n+=(y/=5);
}
return n ;
}
void caut_bin( )
{
int pas=1<<L , r=0;
while(pas!= 0)
{
if(zero(r+pas) < p)
r+=pas;
pas/=2;
}
if(zero(r+1+pas) != p )
out<<"-1";
else
out<<r+1;
}
int main()
{
in>>p;
caut_bin( );
return 0;
}