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. [洛谷P2747] [USACO5.4]周游加拿大Canada Tour

    洛谷题目链接:[USACO5.4]周游加拿大Canada Tour 题目描述 你赢得了一场航空公司举办的比赛,奖品是一张加拿大环游机票.旅行在这家航空公司开放的最西边的城市开始,然后一直自西向东旅行, ...

  2. C11关键字&字面值改善

    1.原始字面值改善 原始字面值可以直接表示字符串的实际含义,但是一些特殊字符就需要转义. std::string str = "D:\A\B\test.txt"; std::cou ...

  3. java多线程机制1(线程创建的两种方式)

    进程:正在运行的程序.(即程序在内存中开辟了一片空间) 线程:是进程的执行单元. 一个进程至少包含了一个多个线程. 多线程是不是可以提高效率:多线程可以合理的利用系统的资源,提高效率是相对的.因为cp ...

  4. R0—New packages for reading data into R — fast

    小伙伴儿们有福啦,2015年4月10日,Hadley Wickham大牛(开发了著名的ggplots包和plyr包等)和RStudio小组又出新作啦,新作品readr包和readxl包分别用于R读取t ...

  5. angular 开发之proxy

    创建proxy配置文件proxy.conf.json 内容如下  {   "/api/*": { "target": "https://abc.com ...

  6. MySql 复制表命令

    1.只复制表结构到新表 CREATE TABLE 新表 SELECT * FROM 旧表 WHERE 1=2; 或 CREATE TABLE 新表 LIKE 旧表 ; 注意上面两种方式,前一种方式是不 ...

  7. C语言实现线性表(链式存储方式)

    #include <stdio.h> #include <stdlib.h> //提供malloc()原型 typedef struct LNode *List; typede ...

  8. 机器学习-kNN(1)

    一 kNN算法简介 kNN(K-Nearest Neighbor)工作原理:存在一个样本数据集合,也称为训练样本集,并且样本集中每个数据都存在标签,即我们知道样本集中每一数据与所属分类对应的关系.输入 ...

  9. 爬虫实战--基于requests和beautifulsoup的妹子网图片爬取(福利哦!)

    #coding=utf-8 import requests from bs4 import BeautifulSoup import os all_url = 'http://www.mzitu.co ...

  10. 深入理解Spring系列之十一:SpringMVC-@RequestBody接收json数据报415

    转载 https://mp.weixin.qq.com/s/beRttZyxM3IBJJSXsLzh5g 问题原因 报错原因可能有两种情况: 请求头中没有设置Content-Type参数,或Conte ...