Pagini recente » Cod sursa (job #2380553) | Cod sursa (job #3172370) | Cod sursa (job #77508) | Cod sursa (job #2704110) | Cod sursa (job #2074308)
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
unsigned long long p;
int verif(unsigned long long n)
{
unsigned long long cnt=0,cat=0;
cat=n/5;
cnt=cat;
while(cat)
{
cat/=5;
cnt+=cat;
}
if(cnt<p)
return 0;
if(cnt==p)
return 2;
return 1;
}
void cautbin()
{
unsigned long long r=0,pas=1LL<<63;
while(pas)
{
if(verif(r+pas)==0)
r+=pas;
pas/=2;
}
if(verif(r+1)==2)
out<<r+1;
else
out<<-1;
}
int main()
{
in>>p;
cautbin();
return 0;
}