您的位置:首页 > 其它

CodeForces 633B A Trivial Problem(找规律)

2017-03-12 12:45 357 查看
题目:

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! = 120, 6! = 720, 7! = 5040, 8! = 40320 and 9! = 362880.

思路:

这个题是求阶乘尾数的0的个数,2*5等于10,这样就出现了0,所以我们找5的个数就行了

代码:

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define N 999999+20
#define M 200010
#define MOD 1000000000+7
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
int num=0,b=5,c,n;
scanf("%d",&n);
while(num<=n)
{
c=b;
while(c%5==0)
{
num++;
c/=5;
}
if(num==n)
{
printf("5\n");
for(int i=0; i<5; i++)
printf("%d ",b+i);
return 0;
}
b+=5;
}
printf("0\n");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: