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.

题意:给一个m,问哪些数的阶乘的末尾0的个数为m;

思路:末尾0的个数为这些数中有多少个5,2的个数一定大于5,所以只需找5的个数就行;

AC代码:

#include <bits/stdc++.h>
using namespace std;
int main()
{
int m;
scanf("%d",&m);
int num,x,sum=0;
for(int i=1;i<=100000;i++)
{
num=1;
x=i;
while(1)
{
if(x%5==0)
{
num++;
x=x/5;
}
else break;
}
sum+=num;
if(sum==m)
{
cout<<"5"<<"\n";
for(int j=5*i;j<5*i+5;j++)
{
printf("%d ",j);
}
return 0;
}
else if(sum>m)
{
break;
}
}
cout<<"0";
return 0;
}

codeforces 633B B. A Trivial Problem(数论)的更多相关文章

  1. CodeForces - 633B A Trivial Problem 数论-阶乘后缀0

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

  2. Codeforces 633B A Trivial Problem

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

  3. 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 ...

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

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

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  8. Codeforces 798C - Mike and gcd problem(贪心+数论)

    题目链接:http://codeforces.com/problemset/problem/798/C 题意:给你n个数,a1,a2,....an.要使得gcd(a1,a2,....an)>1, ...

  9. 【codeforces 442B】 Andrey and Problem

    http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...

随机推荐

  1. SVN版本号控制软件-图片含义具体解释

    转载请注明出处:http://blog.csdn.net/zhuwentao2150/article/details/51195154 自己定义SVN图标显示风格 SVN的图标是能够自己定义风格的 右 ...

  2. iphone开发技术要学习的内容

    一.iOS基础 1 开发环境搭建以及IOS组件.框架的概要介绍. 2 mac操作系统与iOS操作系统 3 xcode IDE开发环境的初始 二.C语言基础 1数据类型.表达式与控制流程语句 2数组.函 ...

  3. js中return;return true return false 的区别

    return 定义: return 语句会 终止函数的执行 并 返回函数的值. 注意这两个: 1.终止函数的执行 2.返回函数的值 返回函数的值这里就不过多叙述了,就是 return 变量 先看下面的 ...

  4. python入门课程 第一章 课程介绍

    1-1 Python入门课程介绍特点:    优雅.明确.简单适合领域:    web网站和各种网络服务    系统工具和脚本    作为"胶水"语言把其他语言开发的模块包装起来方 ...

  5. 将PHP 5.3.3 (cli)升级到PHP 5.6.31 (cli)

    centos默认系统安装的是php5.3 [root@sz-local1 scripts]# rpm -qa |grep phpphp-pdo-5.3.3-47.el6.x86_64php-mysql ...

  6. Visual Studion 2013 HTML 如何打开设计图

    Visual Studion 2013 HTML 没有设计视图? 在解决方案中对要打开的HTML文件 右键-->打开方式-->HTML(Web窗体)编辑器 原地址>>:http ...

  7. android菜鸟学习笔记20----Android数据存储(四))Android数据库操作

    Android内置了一个名为SQLite的关系型数据库,这是一款轻量型的数据库,操作十分简便.SQLite与别的数据库不同的是,它没有数据类型.可以保存任何类型的数据到你所想要保存的任何表的任何列中. ...

  8. Every norm is a convex function

    https://ipfs.io/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Convex_function.html Every  ...

  9. php数据类型的true和false

  10. python数据分析之:时间序列二

    将Timestamp转换为Period 通过使用to_period方法,可以将由时间戳索引的Series和DataFrame对象转换为以时期索引 rng=pd.date_range('1/1/2000 ...