题意:
问所有x,使得x阶乘的末尾恰好有n个0
思路:
计算阶乘的末尾0的个数就是计算这个数中有多少个5的倍数
然后直接暴力就可以了
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
#define max_ 100010
#define mod 1000000007
#define inf 0x3f3f3f3f
int m;
int cal(int n)
{
int ans=0;
while(n)
{
ans+=n/5;
n/=5;
}
return ans;
}
int main(int argc, char const *argv[]) {
scanf("%d",&m);
vector<int>v;
for(int i=1;i<=1000000;i++)
{
if(cal(i)==m)
{
v.push_back(i);
}
}
printf("%d\n",v.size());
for(int i=0;i<v.size();i++)
{
printf("%d%c",v[i]," \n"[i==v.size()-1] );
}
return 0;
}