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’    输出个数 并按照升序输出这些数

题解:数学知识  涨姿势

我们知道阶乘下 产生‘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 数学的更多相关文章

  1. Manthan, Codefest 16 E. Startup Funding ST表 二分 数学

    E. Startup Funding 题目连接: http://codeforces.com/contest/633/problem/E Description An e-commerce start ...

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

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

  3. Manthan, Codefest 16

    暴力 A - Ebony and Ivory import java.util.*; import java.io.*; public class Main { public static void ...

  4. CF Manthan, Codefest 16 B. A Trivial Problem

    数学技巧真有趣,看出规律就很简单了 wa 题意:给出数k  输出所有阶乘尾数有k个0的数 这题来来回回看了两三遍, 想的方法总觉得会T 后来想想  阶乘 emmm  1*2*3*4*5*6*7*8*9 ...

  5. Manthan, Codefest 16 H. Fibonacci-ish II 大力出奇迹 莫队 线段树 矩阵

    H. Fibonacci-ish II 题目连接: http://codeforces.com/contest/633/problem/H Description Yash is finally ti ...

  6. Manthan, Codefest 16 D. Fibonacci-ish

    D. Fibonacci-ish time limit per test 3 seconds memory limit per test 512 megabytes input standard in ...

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

  8. Manthan, Codefest 16 -C. Spy Syndrome 2

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  9. Manthan, Codefest 16 -A Ebony and Ivory

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

随机推荐

  1. java基础面试题:写clone()方法时,通常都有一行代码,是什么?

    clone()方法 与new constructor()构造器创建对象不同 是克隆一个新的对象 package com.swift; public class Clone_Test { public ...

  2. 64位系统InlineHook

    APIHook64Class.h #ifndef APIHOOK64CLASS_H_ #define APIHOOK64CLASS_H_ #include <Windows.h> clas ...

  3. 详解三种java实现多线程的方式

    java中实现多线程的方法有两种:继承Thread类和实现runnable接口. 1.继承Thread类,重写父类run()方法 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  4. 最全的PHP函数详解

    usleep() 函数延迟代码执行若干微秒. unpack() 函数从二进制字符串对数据进行解包. uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID. time_sleep_unti ...

  5. JZOJ 5771. 【NOIP2008模拟】遨游

    5771. [NOIP2008模拟]遨游 (File IO): input:trip.in output:trip.out Time Limits: 2000 ms  Memory Limits: 2 ...

  6. Python学习笔记(五)之Python操作Redis、mysql、mongodb数据库

    操作数据库 一.数据库 数据库类型主要有关系型数据库和菲关系型数据库. 数据库:用来存储和管理数的仓库,数据库是通过依据“数据结构”将数据格式化,以记录->表->库的关系存储.因此数据查询 ...

  7. centos6.9系统安装

    1. 选择系统及下载 CentOS 5.x CentOS 6.x 50% 6.9 CentOS 7.x 50% 7.2 centos 6.9 centos 7. 最新版 https://wiki.ce ...

  8. [Uva623]500!(高精)

    Description 求N! \(N \leq 1000\) Sample Input 10 30 50 100 Sample Output 10! 3628800 30! 265252859812 ...

  9. (HTML)A标签伪元素选择器的继承关系

    ①如果a:link{}也存在,那么不管a{}放到哪里,a{}和a:link{}冲突的属性都会采用a:link{}的,不冲突的属性若存在a{}中,会被a:link{}. a:visited{} .a:h ...

  10. 《鸟哥的Linux私房菜》学习笔记(4)——用户和组

    一.用户和组的基本概念                                              1.用户 用户:用于获取计算机资源或服务的标识符,比如用户名.计算机处理的是UID,用 ...