Pagini recente » Monitorul de evaluare | Cod sursa (job #1692052) | Cod sursa (job #2188766) | Cod sursa (job #498963) | Cod sursa (job #830433)
Cod sursa(job #830433)
#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;