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. Downloading jQuery

    Compressed and uncompressed copies of jQuery files are available. The uncompressed file is best used ...

  2. 经常使用的eclipse快捷键-也适合sts

    非常多内容来自互联网和已知文件,本人仅整理. 1. ctrl+shift+r:打开资源 这可能是全部快捷键组合中最省时间的了. 这组快捷键能够让你打开你的工作区中不论什么一个文件.而你仅仅须要按下文件 ...

  3. 公告板shader

    Shader "Custom/LightPoint" { Properties { _MainTex ("Main Tex", 2D) = "whit ...

  4. jquery基础研究学习【HTML】

    jQuery HTMLjQuery 捕获jQuery 设置jQuery 添加元素jQuery 删除元素jQuery CSS 类jQuery css() 方法jQuery 尺寸 笔记:

  5. 【BZOJ2724】[Violet 6]蒲公英 分块+二分

    [BZOJ2724][Violet 6]蒲公英 Description Input 修正一下 l = (l_0 + x - 1) mod n + 1, r = (r_0 + x - 1) mod n ...

  6. 爬虫入门【3】BeautifulSoup4用法简介

    快速开始使用BeautifulSoup 首先创建一个我们需要解析的html文档,这里采用官方文档里面的内容: html_doc = """ <html>< ...

  7. nginx搭建服务

    1.当然首先是安装nginx :http://nginx.org/en/download.html 2.一波安装之后 3.在nginx 文件夹打开命令行:cmd 4.开启nginx 服务命令:star ...

  8. 《linux 内核全然剖析》 fork.c 代码分析笔记

    fork.c 代码分析笔记 verifiy_area long last_pid=0; //全局变量,用来记录眼下最大的pid数值 void verify_area(void * addr,int s ...

  9. Hadoop初体验(续)--YARN

    1.Hadoop已经安装完成并启动成功 复制mapred-site.xml.template重命名为mapred-site.xml /etc/hadoop/mapred-site.xml.templa ...

  10. cordova 获取地理位置

    第一步,引入插件 cordova plugin add cordova-plugin-geolocation 第二步, <!DOCTYPE html> <html> <h ...