1.二分答案求最小
2.结尾为0就是分解质因数5的个数,有多少5的倍数其阶乘末尾就有多少个0
求n阶乘中5因子的个数的公式就是n/5+n/25+n/125+...+n/5^i;
代码如下,记得判断-1的情况

#include<bits/stdc++.h>
using namespace std;
#define N 100011
typedef long long ll;
typedef pair<ll,int> PII;
ll k;
ll an;
bool check(ll x)
{
ll c=0;
ll s=5;
while(x/s)
{
c+=x/s;
if(c>=k) return true;
s*=5;
}
return false;
}
ll c1(ll x)
{
ll c=0;
ll s=5;
while(x/s)
{
c+=x/s;
s*=5;
}
if(c==k) return true;
return false;
}
int main()
{
cin>>k;
ll l=0,r=0x3f3f3f3f3f3f3f3fLL;
while(l<=r)
{
ll m=(l+r)>>1;
if(check(m))
{
an=m;
r=m-1;
}else l=m+1;
}
if(c1(an))cout<<an;
else cout<<"-1";
return 0;
}
///10000 200;