Manthan, Codefest 16 B 数学
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’ 输出个数 并按照升序输出这些数
题解:数学知识 涨姿势
我们知道阶乘下 产生‘0’位只能是 2*5=10产生‘0’位
那么‘0’位的个数取决于‘2’和‘5’的个数
相比之下‘5’的个数更少 所以末尾‘0’的个数取决于阶乘中‘5’的数
所以可以预处理出所有数含有因数‘5’的个数 也就代码中fun的作用
vector存储为一个数x 对应的x!中5的个数也就是结果。
#include<bits/stdc++.h>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
#define bug(x) printf("%%%%%%%%%%%%%",x);
#define inf 1e8
using namespace std;
#define ll __int64
int fun( int x)
{
int flag=;
if(x%==)
{
while(x%==)
{
x/=;
flag++;
}
}
return flag;
}
vector<int>ve[];
int m;
int main()
{
scanf("%d",&m);
int gg=;
for(int i=;i<=;i++)
{
gg+=fun(i);
if(gg==m)
ve[gg].push_back(i);
}
printf("%d\n",ve[m].size());
if(ve[m].size())
cout<<ve[m][];
for(int i=;i<ve[m].size();i++)
cout<<" "<<ve[m][i];
cout<<endl;
return ;
}
Manthan, Codefest 16 B 数学的更多相关文章
- Manthan, Codefest 16 E. Startup Funding ST表 二分 数学
E. Startup Funding 题目连接: http://codeforces.com/contest/633/problem/E Description An e-commerce start ...
- 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
暴力 A - Ebony and Ivory import java.util.*; import java.io.*; public class Main { public static void ...
- CF Manthan, Codefest 16 B. A Trivial Problem
数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k 输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想 阶乘 emmm 1*2*3*4*5*6*7*8*9 ...
- Manthan, Codefest 16 H. Fibonacci-ish II 大力出奇迹 莫队 线段树 矩阵
H. Fibonacci-ish II 题目连接: http://codeforces.com/contest/633/problem/H Description Yash is finally ti ...
- Manthan, Codefest 16 D. Fibonacci-ish
D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard in ...
- 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 ...
- Manthan, Codefest 16 -C. Spy Syndrome 2
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Manthan, Codefest 16 -A Ebony and Ivory
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
随机推荐
- 纯js实现淘宝商城轮播图
需求: 循环无缝自动轮播3张图片,点击左右箭头可以手动切换图片,鼠标点击轮播图下面的小圆点会跳转到对应的第几张图片.鼠标放到轮播图的图片上时不再自动轮播,鼠标移开之后又继续轮播.效果图: 下面是htm ...
- Oracle表连接学习笔记
目录 一.表连接类型 1.1 内连接 1.2 外连接 二.表连接方法 2.1 表连接方法分类 2.2 表连接方法特性区别 @ 一.表连接类型 表连接类型可以分为:内连接.外连接,在看<收获,不止 ...
- Incorrect key file for table './xx_db/xx_table.MYI'; try to repair it
解决办法: 可以先运行 CHECK TABLE 表名 检查下是否存在错误. 然后运行 REPAIR TABLE 表名 进行修复.
- c++中的结构化语句 判断语句if 分支语句switch 循环语句 while 和 do while 循环语句for的使用
作业1: 使用if语句,根据1~7的数字,输出今天是星期几?的程序. 方法一,直接使用单独的if语句 #include <iostream> using namespace std; in ...
- centos下 将(jgp、png)图片转换成webp格式
由于项目要求需要将jpg.png类型的图片 转换成webp格式,最开始使用了php gd类库里 imagewebp 方法实现,结果发现转换成的webp格式文件会偶尔出现空白内容的情况.像创建了一个透 ...
- JavaScript 资源大全中文版
我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-javascript 是 sorrycc 发起维护的 JS 资源列表,内容包括:包管理器.加 ...
- C++构造函数使用的多种方法
// classes and uniform initialization #include <iostream> using namespace std; class Circle { ...
- Java的多态性Polymorphism
原文地址:http://www.cnblogs.com/jack204/archive/2012/10/29/2745150.html Java中多态性的实现 什么是多态 面向对象的三大特性:封装.继 ...
- 如何使用DroidPlugin——DroidPlugin初体验
最近研究了下360的黑科技--DroidPlugin 刚开始不知道怎么用,于是看了这篇博客:http://www.jianshu.com/p/f1217cce93ef 算是引导了我,于是开始自己写写 ...
- MySQL基础4-SQL简单查询(单表)
1.SELECT语句 2.运算符的优先级 利用Navicat中的查询方法: 栗子1:查询所有货品信息 栗子2:查询所有货品的id,productName,salePrice 当查询错误的时候出现的界面 ...