Pagini recente » Cod sursa (job #3226706) | Cod sursa (job #2478455) | Cod sursa (job #2769753) | Cod sursa (job #648347) | Cod sursa (job #830305)
Cod sursa(job #830305)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p;
int zero(int x)
{
int nr=0;
while(x != 0)
{
nr += x / 5;
x = x / 5;
}
return nr;
}
int cautb(int p)
{
int i=0,pas=1<<29;
while(pas != 0)
{
if(zero(i+pas) < p)
i+=pas;
pas/=2;
}
return i;
}
int main()
{
int t,p;
in >> p;
t = cautb(p) + 1;
if(zero(t) == p)
out << t;
else
out << -1;
return 0;
}