Pagini recente » Cod sursa (job #1271546) | Cod sursa (job #1079396) | Cod sursa (job #1273204) | Cod sursa (job #447230) | Cod sursa (job #1809939)
#include <fstream>
using namespace std;
const long long L=30;
ifstream in("fact.in");
ofstream out("fact.out");
int zero(int nr)
{
int sum=0;
while(nr)
{
nr=nr/5;
sum=sum+nr;
}
return sum;
}
int caut(int l,int x)
{
int r=0,pas=1<<L;
while(pas!=0)
{
if(r+pas<=l&&zero(r+pas)<x)
{
r+=pas;
}
pas/=2;
}
if(zero(1+r)==x)
{
return 1+r;
}
else
{
return -1;
}
}
int main()
{
int n;
in>>n;
out<<caut(30,n);
}