Pagini recente » Cod sursa (job #1634108) | Cod sursa (job #2806911) | Cod sursa (job #675700) | Infoarena Monthly 2012 - Runda 9, Clasament | Cod sursa (job #1472301)
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p;
inline int Count(int n){
int cnt=0;
while(n)
{
cnt+=n/5;
n/=5;
}
return cnt;
}
inline void Search(){
int st=1,dr=100000000000,m,ans=-1;
while(st<=dr)
{
m=(st+dr)/2;
if(Count(m)<p)
{
st=m+1;
}
else
dr=m-1;
}
if(Count(st)==p)
g<<st;
else
g<<"-1";
}
int main()
{
f>>p;
Search();
return 0;
}