Pagini recente » Cod sursa (job #1593623) | Cod sursa (job #981200) | Cod sursa (job #1219202) | Cod sursa (job #911647) | Cod sursa (job #2438171)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p;
int sol(int x)
{
int t=5,cont=0,aux;
while(x>=t)
{
x/=t;
cont+=x;
}
return cont;
}
int cb()
{
int poz=0;
for(int i=(1<<30);i>0;i=i/2)
{
if(poz+i<=1000000005)
{
if(sol(poz+i)<p)
{
poz+=i;
}
}
}
if(sol(poz+1)==p)
return poz+1;
else return -1;
}
int main()
{
in>>p;
out<<cb();
return 0;
}