Pagini recente » Cod sursa (job #1983117) | Cod sursa (job #1429702) | Cod sursa (job #3238618) | Cod sursa (job #2629731) | Cod sursa (job #2924066)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int n,p;
int nrzerouri(int n)
{ int nr1=0,nr2=0;
for(int i=2;i<=n;i++)
{ int x=i;
while(x%2==0)
{ nr1++;
x/=2;
}
while(x%5==0)
{ nr2++;
x/=5;
}
}
return min(nr1,nr2);
}
int main()
{ fin>>p;
bool gasit=0;
int n=0;
while(nrzerouri(n)<=p)
{
n++;
if(nrzerouri(n)==p)
{
fout<<n;
gasit=1;
break;
}
}
if(gasit==0) fout<<-1;
return 0;
}