A Trivial Problem

Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you among those great programmers who can solve this problem?

Input

The only line of input contains an integer m (1 ≤ m ≤ 100 000) — the required number of trailing zeroes in factorial.

Output

First print k — the number of values of n such that the factorial of n ends with m zeroes. Then print these k integers in increasing order.

Example
Input
1
Output
5
5 6 7 8 9 
Input
5
Output
0
Note

The factorial of n is equal to the product of all integers from 1 to n inclusive, that is n! = 1·2·3·...·n.

In the first sample, 5! = 120, 6! = 720, 7! = 5040, 8! = 40320 and 9! = 362880.

题意:让你找N的阶乘的末尾有m个0的数有多少,并输出n.

解法:因为末尾是0和5的个数有关系,n!=n*(n-1)*(n-2)*.......*1,里面有多少个5,那么结果的末尾就有多少个0

#include<stdio.h>
#include<string.h>
int a[10000];
int main()
{
    int n;
    while(scanf("%d",&n)!=-1)
    {
        int i,j;
        for(i=1;n>0;i++)//1*2*3*.....*(n-1)*找能被5整除的数
        {
        int we=i;
        while(we%5==0)//找到了就零的个数--
            {
               we /= 5;
                n--;
            }
        }
        if(n<0)
        {
            printf("0\n");
        }
        else
        {
            printf("5\n");
            for(int j=i-1;j<=i+3;j++)
            {
                if(j<i+3)
                printf("%d ",j);
                if(j==i+3)
                    printf("%d\n",j);
            }
        }
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值