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. 1
Output
  1. 5
    5 6 7 8 9
Input
  1. 5
Output
  1. 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的个数也就是结果。

  1. #include<bits/stdc++.h>
  2. #define ll __int64
  3. #define mod 1e9+7
  4. #define PI acos(-1.0)
  5. #define bug(x) printf("%%%%%%%%%%%%%",x);
  6. #define inf 1e8
  7. using namespace std;
  8. #define ll __int64
  9. int fun( int x)
  10. {
  11. int flag=;
  12. if(x%==)
  13. {
  14. while(x%==)
  15. {
  16. x/=;
  17. flag++;
  18. }
  19. }
  20. return flag;
  21. }
  22. vector<int>ve[];
  23. int m;
  24. int main()
  25. {
  26. scanf("%d",&m);
  27. int gg=;
  28. for(int i=;i<=;i++)
  29. {
  30. gg+=fun(i);
  31. if(gg==m)
  32. ve[gg].push_back(i);
  33. }
  34. printf("%d\n",ve[m].size());
  35. if(ve[m].size())
  36. cout<<ve[m][];
  37. for(int i=;i<ve[m].size();i++)
  38. cout<<" "<<ve[m][i];
  39. cout<<endl;
  40. return ;
  41. }

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. cout对象一些常用方法的总结

    cout.precision(n); 这个方法的功能是,设置精度为n,返还值是上一次的设置精度. #include <iostream> using namespace std; int ...

  2. js当中mouseover和mouseout多次触发(非冒泡)

    JS当中,mouseover和mouseout多次触发事件,不光是冒泡会产生,就是不冒泡,在一定条件下 ,也会产生多次触发事件: 例如下面的结构的情况下,我在class="ceng_up f ...

  3. python-kafka源码解析之socketpair

    socket基本操作包括:socket()函数创建socket文件描述符,唯一标识一个socket.bind()函数,将ip:port和socket绑定listen()函数来监听这个socket,假如 ...

  4. pycharm在同目录下import,pycharm会提示错误,但是可以运行

    原因是:    pycharm不会将当前文件目录自动加入自己的sourse_path. 解决方案:右键make_directory as-->sources path将当前工作的文件夹加入sou ...

  5. 背景透明度处理 兼容IE

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 打开POST传参的弹出窗口

    //穿件 function openPostPopWindow(url,param,target){ var $form = $("<form></form>&quo ...

  7. Visual Studio的下载安装

    下载地址: 下载Visual Studio Code https://code.visualstudio.com/ 安装扩展包 安装图标 View->Extensions 搜索Icon 安装Ma ...

  8. ob缓存的基本使用

    在页面 加载的时候 如果 图片 很多 很大 会造成页面的阻塞降低用户体验 我们在点击页面的时候可以使用OB缓存 整个页面, 当用户点击的时候直接请求的是我们预先准备好的html页面 .也降低了我们数据 ...

  9. 牛客练习赛42 A 字符串

    题目描述 给定两个等长的由小写字母构成的串 A,BA,B,其中 |A|=|B|=n|A|=|B|=n. 现在你需要求出一个子区间 [l,r][l,r] 使得 LCP(A[l,r],B[l,r])×LC ...

  10. pycharm中某些方法被标黄的原因及解决办法

    在编辑python文件时,会遇到上图所示,函数方法被标黄的问题,但是不影响使用. 引起原因:,如果不报错说明,这是因为你配置的python解释器中有该方法,但是pycharm没有找到这个方法,即加载失 ...