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.

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.

#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;
}

cf 633B A trivial problem的更多相关文章

  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. CodeForces - 633B A Trivial Problem 数论-阶乘后缀0

    A Trivial Problem Mr. Santa asks all the great programmers of the world to solve a trivial problem. ...

  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. Manthan, Codefest 16(B--A Trivial Problem)

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

  5. 把一个序列转换成严格递增序列的最小花费 CF E - Sonya and Problem Wihtout a Legend

    //把一个序列转换成严格递增序列的最小花费 CF E - Sonya and Problem Wihtout a Legend //dp[i][j]:把第i个数转成第j小的数,最小花费 //此题与po ...

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

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

  7. E - A Trivial Problem(求满足x!的尾数恰好有m个0的所有x)

    Problem description Mr. Santa asks all the great programmers of the world to solve a trivial problem ...

  8. CF Manthan, Codefest 16 B. A Trivial Problem

    数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k  输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想  阶乘 emmm  1*2*3*4*5*6*7*8*9 ...

  9. 【dp/贪心】CF 780 (Div. 3), problem: (C) Get an Even String

    Problem - C - Codeforces 难度: 1300 input 6 aabbdabdccc zyx aaababbb aabbcc oaoaaaoo bmefbmuyw output ...

随机推荐

  1. 你知道吗?Java开发的10位牛人

    James Gosling 1983年,Gosling获得了加州大学的计算机科学学士学位.1990年,他获得了卡内基梅隆大学的计算机科学博士学位,师从Bob Sproull.在攻读博士期间,他自己开发 ...

  2. 好久没写了,SQLSERVER服务丢失后怎么办

    服务器突然中了病毒,查杀后,结果两个服务也丢了, 从其他机器上COPY了两个EXE过来,编写这两个服务就搞定了,不用重装MSSQL2005了 sc create MSSQLSERVER binpath ...

  3. Linux sqlite3基本命令

    简介sqlite3一款主要用于嵌入式的轻量级数据库,本文旨在为熟悉sqlite3基本命令提供技术文档. 备注:本文所有操作均在root用户下进行. 1.安装sqlite3 ubuntu下安装sqlit ...

  4. utsrelease.h 包含svn信息

    utsrelease.h是一个自动生成的文件,没有办法修改,但这个数据是根据Makefile和.config的内容进行生成的,通过修改这两个文件的内容,可以改变!/usr/src/linux/Make ...

  5. [node.js] async/await如何优雅处理异常?

    node.js的世界,从callback开始,不会止于async. 所有人都在骂为什么不能完全进化,其实我感觉这就是老外的细心,为了承上.这也就是为什么async其实就是promise一样,假如不是一 ...

  6. Python中如何Debug

    debug是编码是非常重要的调试技巧,通过在运行过程中设置断点,帮助开发人员更好的理解运行过程. Python中debug不像JAVA或者C++那样在IDE中设置断点那么直观. Python的debu ...

  7. 「caffe编译bug」.build_release/lib/libcaffe.so: undefined reference to cv::imread

    转自:https://www.douban.com/note/568788483/ CXX/LD -o .build_release/tools/convert_imageset.bin.build_ ...

  8. php 7.3.3安装问题记录

    1.checking for libzip... not foundconfigure: error: Please reinstall the libzip distribution 参考:http ...

  9. Linux中涉及到环境变量的文件

    1. 系统级 (a) /etc/profile : 在用户登录操作系统时,定制用户环境的第一个文件,应用于登录的每一个用户 ==> 该文件一般调用/etc/bash.bashrc文件 (b)/e ...

  10. java之正则表达式、日期操作

    正则表达式和日期操作 正则表达式简介 正则表达式就是使用一系列预定义的特殊字符来描述一个字符串的格式规则,然后使用该格式规则匹配某个字符串是否符合格式要求. 作用:比如注册邮箱,邮箱有用户名和密码,一 ...