Pagini recente » Cod sursa (job #1883878) | Cod sursa (job #1113927) | Cod sursa (job #2477680) | Cod sursa (job #2592967) | Cod sursa (job #2534940)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int zerouri(int x)
{
int cnt=0;
while(x>0)
{
cnt+=x/5;
x/=5;
}
return cnt;
}
int main()
{
long long p,step,pos;
fin >> p;
step=1;
while(step<100000000)
step=step<<1;
step=step>>1;
pos=0;
while(step>0)
{
if(pos+step<=100000000 && zerouri(step+pos)<p)
pos+=step;
step=step>>1;
}
if(zerouri(pos+1)==p)
fout << pos+1;
else
fout << -1;
return 0;
}