CF 633B Problema Trivial Explicação

#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<numeric>//STL数值算法头文件
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<functional>//模板类头文件
using namespace std;

const int INF=0x3f3f3f3f;
const int maxn=500100;

int m,cnt;
int num[maxn],a[maxn];
int fun(int n)
{
    int ans=0;
    while(n)
    {
        n/=5;
        ans+=n;
    }
    return ans;
}

int main()
{
    for(int i=0; i<maxn; i++)
        a[i]=fun(i);
    while(~scanf("%d",&m))
    {
        cnt=0;
        int i;
        for(i=0; i<maxn; i++)
        {
            if(a[i]==m)
            {
                num[cnt++]=i;
            }
        }
        printf("%d\n",cnt);
        if(cnt)
        {
            for(i=0; i<cnt; i++)
            {
                if(i) printf(" ");
                printf("%d",num[i]);
            }
            printf("\n");
        }
    }
    return 0;
}

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN = 1e9;

int fun(int n)
{
    int cnt = 0;
    while(n)
    {
        n/=5;
        cnt+=n;
    }
    return cnt;
}
int Two(int l, int r, int m)
{
    int ans = 0;
    while(r >= l)
    {
        int mid = (l + r) >> 1;
        int res = fun(mid);
        if(res < m)
            l = mid + 1;
        else if(res >= m)
        {
            r = mid - 1;
            ans = mid;
        }
    }
    return ans;
}
int main()
{
    int m;
    while(cin >> m)
    {
        int l = 1, r = MAXN;
        int L = Two(l, r, m), R = Two(l, r, m+1);
        if(L == 0 || fun(R-1) != m) cout << 0 << endl;
        else
        {
            cout << R - L << endl;
            for(int i = L; i <= R-1; i++)
            {
                if(i > L) cout << " ";
                cout << i;
            }
            cout << endl;
        }
    }
    return 0;
}
Determined Duck