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. ② 设计模式的艺术-08.桥接(Bridge)模式

    为什么需要桥接(Bridge)模式 商城系统中常见的商品分类,以电脑为类,如何良好的处理商品分类销售的问题? 采用多层继承结构: 多层继承结构代码示例 Computer.java package co ...

  2. CSS浏览器兼容问题集-第二部分

    11.高度不适应 高度不适应是当内层对象的高度发生变化时外层高度不能自动进行调节,特别是当内层对象使用margin 或paddign 时.   例:  #box {background-color:# ...

  3. spring 添加controller返回值绑定

    @EnableWebMvc @Configuration public class Config { @Autowired private RequestMappingHandlerAdapter h ...

  4. 【洛谷 P1501】 [国家集训队]Tree II(LCT)

    题目链接 Tree Ⅱ\(=\)[模板]LCT+[模板]线段树2.. 分别维护3个标记,乘的时候要把加法标记也乘上. 还有就是模数的平方刚好爆\(int\),所以开昂赛德\(int\)就可以了. 我把 ...

  5. 21、利用selenium进行Web测试

    一.案例实施步骤思路分析 1.寻包 2.指定浏览器(实例化浏览器对象) 3.打开项目 4.找到元素(定位元素) 5.操作元素 6.暂停 7.关闭二.元素定位[重点] 1.id 说明:通过元素的id属性 ...

  6. 【译】第一篇 SQL Server代理概述

    本篇文章是SQL Server代理系列的第一篇,详细内容请参考原文. SQL Server代理是SQL Server的作业调度和告警服务,如果使用得当,它可以大大简化DBA的工作量.SQL Serve ...

  7. iTextSharp操作pdf之pdfCreater

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. bootstrap table 双击可编辑,添加、删除行

    html: <table class="table table-bordered" id="para_table"> <tr> < ...

  9. angular项目中使用angular-material2

    Step 1: Install Angular Material and Angular CDK npm install --save @angular/material @angular/cdk n ...

  10. Git提交记住用户名和密码

    https://www.baidu.com/link?url=R14MHMloypfAfIeiQwCINfY1AZlcoSU7-tYdnqC1PxfmFKs4TWzLOPdtyJbWVfqMqOkRx ...