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 mzeroes. 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个数,输出n!满足条件的所有n值。

数论题。由于因子里含有偶数,所以非零末尾一定是偶数。产生0的因数一定包含5,所以题目就转化为寻找阶乘因子中含有5的个数。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<set>
#include<algorithm>
#define MAX 1005
#define INF 0x3f3f3f3f
using namespace std; int a[MAX]; int main()
{
int n,c,i,j;
scanf("%d",&n);
c=;
for(i=;i<=;i++){ //注意这里是枚举阶乘的因子,需要大于后缀0最长的情况
int ii=i;
while(ii%==&&ii>){
c++;
ii/=;
}
if(c==n){
printf("5\n");
printf("%d",i);
for(j=i+;j<=i+;j++){
printf(" %d",j);
}
break;
}
else if(c>n){
printf("0\n");
break;
}
}
return ;
}

CodeForces - 633B A Trivial Problem 数论-阶乘后缀0的更多相关文章

  1. Codeforces 633B A Trivial Problem

    B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  2. UVA 10061 How many zero's and how many digits ? (m进制,阶乘位数,阶乘后缀0)

    题意: 给出两个数字a和b,求a的阶乘转换成b进制后,输出 (1)后缀中有多少个连续的0? (2)数a的b进制表示法中有多少位? 思路:逐个问题解决. 设a!=k.  k暂时不用直接转成b进制. (1 ...

  3. codeforces 633B B. A Trivial Problem(数论)

    B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  4. cf 633B A trivial problem

    Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an i ...

  5. HDU 1124 Factorial (阶乘后缀0)

    题意: 给一个数n,返回其阶乘结果后缀有几个0. 思路: 首先将n个十进制数进行质因数分解,观察的得到只有2*5才会出现10.那么n!应含有min(2个数,5个数)个后缀0,明显5的个数必定比2少,所 ...

  6. [E. Ehab's REAL Number Theory Problem](https://codeforces.com/contest/1325/problem/E) 数论+图论 求最小环

    E. Ehab's REAL Number Theory Problem 数论+图论 求最小环 题目大意: 给你一个n大小的数列,数列里的每一个元素满足以下要求: 数据范围是:\(1<=a_i& ...

  7. Manthan, Codefest 16 B. A Trivial Problem 二分 数学

    B. A Trivial Problem 题目连接: http://www.codeforces.com/contest/633/problem/B Description Mr. Santa ask ...

  8. Codeforces 432D Prefixes and Suffixes (KMP、后缀数组)

    题目链接: https://codeforces.com/contest/432/problem/D 题解: 做法一: KMP 显然next树上\(n\)的所有祖先都是答案,出现次数为next树子树大 ...

  9. [CodeForces - 1225D]Power Products 【数论】 【分解质因数】

    [CodeForces - 1225D]Power Products [数论] [分解质因数] 标签:题解 codeforces题解 数论 题目描述 Time limit 2000 ms Memory ...

随机推荐

  1. 观察OnPaint与OnIdle与OnSize事件

    import wx class SketchWindow(wx.Window): def __init__(self, parent, ID): wx.Window.__init__(self, pa ...

  2. Other Linker flags 添加 -Objc导致包冲突

    Other Linker flags 添加 -Objc导致包冲突 先尝试不添加-Objc,不行的话尝试下面的方法. 第三方冲突解决办法: https://www.jianshu.com/p/02846 ...

  3. Gemini.Workflow 双子工作流入门教程二:定义流程:流程节点介绍

    简介: Gemini.Workflow 双子工作流,是一套功能强大,使用简单的工作流,简称双子流,目前配套集成在Aries框架中. 下面介绍本篇教程:流程定义:流程节点属性. 流程节点: 左侧是节点工 ...

  4. node+express上传图片到七牛

    本人微信公众号:前端修炼之路,欢迎关注 最近做项目的时候有一个上传图片的需求,由于没有后端的配合,所以决定自己来搭个服务器,实现上传图片功能.以后如果需要修改成java或者php为后端,直接使用即可, ...

  5. JavaMail发送和接收邮件

    一.JavaMail概述:        JavaMail是由Sun定义的一套收发电子邮件的API,不同的厂商可以提供自己的实现类.但它并没有包含在JDK中,而是作为JavaEE的一部分. 厂商所提供 ...

  6. ansible mysql模块的使用今年

    摘自: https://www.ibm.com/developerworks/cn/linux/1502_lih_ansible/

  7. mooc_java Socket

    Socket通信,TCP协议是面向连接,可靠的,有序的,以字节流的方式发送数据:基于TCP协议实现网络通信的类客户端的Socket类 服务器端的ServerSocket类 -------------- ...

  8. PYTHON 爬虫笔记八:利用Requests+正则表达式爬取猫眼电影top100(实战项目一)

    利用Requests+正则表达式爬取猫眼电影top100 目标站点分析 流程框架 爬虫实战 使用requests库获取top100首页: import requests def get_one_pag ...

  9. PHP按照比例随机

    有这样的需求,在打开链接的时候,随机(按照项目的某个属性的比例随机)跳转到指定的几个项目的某一个项目页面 比如项目A:80  项目B:20 那么跳转到项目A 的比例为80%,项目B的比例为20% 那么 ...

  10. 【Codeforces】894E.Ralph and Mushrooms Tarjan缩点+DP

    题意 给定$n$个点$m$条边有向图及边权$w$,第$i$次经过一条边边权为$w-1-2.-..-i$,$w\ge 0$给定起点$s$问从起点出发最多能够得到权和,某条边可重复经过 有向图能够重复经过 ...