codeforces 633B B. A Trivial Problem(数论)
2 seconds
256 megabytes
standard input
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?
The only line of input contains an integer m (1 ≤ m ≤ 100 000) — the required number of trailing zeroes in factorial.
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.
1
5
5 6 7 8 9
5
0
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(数论)的更多相关文章
- CodeForces - 633B A Trivial Problem 数论-阶乘后缀0
A Trivial Problem Mr. Santa asks all the great programmers of the world to solve a trivial problem. ...
- Codeforces 633B A Trivial Problem
B. A Trivial Problem time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- 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 ...
- Manthan, Codefest 16 B. A Trivial Problem 二分 数学
B. A Trivial Problem 题目连接: http://www.codeforces.com/contest/633/problem/B Description Mr. Santa ask ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces 798C - Mike and gcd problem(贪心+数论)
题目链接:http://codeforces.com/problemset/problem/798/C 题意:给你n个数,a1,a2,....an.要使得gcd(a1,a2,....an)>1, ...
- 【codeforces 442B】 Andrey and Problem
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...
随机推荐
- EasyAR SDK在unity中的简单配置及构建一个简单场景。
首先打开EasyAR的官方网站http://www.easyar.cn/index.html,注册登陆之后,打开首页的开发页面. 下载sdk和Unity Samples. 创建一个unity3d工程N ...
- 安装Linux CentOS与用Xshell实现远程连接
注意,进入后有一个选择skip和OK的,选择skip 网络问题 vi /etc/sysconfig/network-scripts/ifcfg-eth0 //打开网络配置文件 ONBOOT=no ...
- http 长连接 & 短连接
1.意义 同一个TCP连接来发送和接收多个HTTP请求/应答,而不是为每一个新的请求/应答打开新的连接的方法. 2.优 较少的CPU和内存的使用 允许请求和应答的HTTP pipelining 降低网 ...
- CALL TRANSFORMATION 的方法生成XML文件
*&---------------------------------------------------------------------**& Report Z_BARRY_X ...
- shell基础part2
shell基础 一.bash中的变量 1.变量的定义:变量是计算机的内存单元,其中存放的值是可以改变的. 2.变量的设定规则:变量名不能以数字开头:变量的等号两边不能有空格,变量的值如果想有空格必须用 ...
- 3.26课·········window.document对象
1.Window.document对象 一.找到元素: docunment.getElementById("id"):根据id找,最多找一个: var a =docun ...
- 认识CoreData—使用进阶
之前两篇文章都比较偏理论,文字表达比较多一些,但都是干货!学习时先理解理论知识,才能更好的帮助后面的理解.在这篇文章中,将会涉及关于CoreData的一些复杂操作,这些操作会涉及分页查询.模糊查询.批 ...
- c++之默认参数的函数
默认参数,看个例子就明白了 int add(int a=5,int b=6,z=3): int main(){ add():// 全部默认 add(1,5)://第三个参数默认 add(1,2,3): ...
- Data Structure Stack: Reverse a stack using recursion
http://www.geeksforgeeks.org/reverse-a-stack-using-recursion/ #include <iostream> #include < ...
- 【leetnode刷题笔记】Maximum Depth of binary tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...