CF633 B 数论 阶乘末尾有几个0 二分

http://codeforces.com/contest/633/problem/B
B. A Trivial Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
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! = 1206! = 7207! = 50408! = 40320 and 9! = 362880.

额,每次都能遇到一些新的知识点。可喜可贺可喜可贺......

题目大意:就是一个阶乘中有几个0。

首先思考一下,因为在一个数字中,2作为因子的次数肯定比5多。那么就只需要考虑5出现过几次就可以了。然后就是解释一下为什么25的时候是6个0,因为25中有两个5,所以一共就有6个0。

来一个例子

从1到10,连续10个整数相乘:
从1×2×3×4×5×6×7×8×9×10中可以得出其中5的因数有2个,所以它们的乘积末尾有2个0
从1到20,20个整数相乘:从中可以得出其中5的因数有4个,所以它们的乘积末尾有4个0
从1到30,30个整数相乘:从中可以得出其中5的因数有5,但25中有2个5,所以一共是6个,所以它们的乘积末尾有6个0


你可能感兴趣的:(CF633 B 数论 阶乘末尾有几个0 二分)