题目大意

N!末尾0的个数

题解

0只能由2*5产生,所以只要求2,5有多少对即可,又因为10!中5的个数少于2,所以只要求因子5有多少个即可,答案即为N/5+N/25+N/125..

代码:

#include<stdio.h>
int main(void)
{
int T;
scanf("%d",&T);
while(T--)
{
int n,ans=0;
scanf("%d",&n);
while(n)
{
ans+=n/5;
n/=5;
}
printf("%d\n",ans);
}
return 0;
}

POJ1401 - Factorial的更多相关文章

  1. ACM-简单题之Factorial——poj1401

    转载请注明出处:http://blog.csdn.net/lttree Factorial Time Limit: 1500MS   Memory Limit: 65536K Total Submis ...

  2. ACM-简单的主题Factorial——poj1401

    明出处:http://blog.csdn.net/lttree Factorial Time Limit: 1500MS   Memory Limit: 65536K Total Submission ...

  3. Factorial(hdu 1124)

    Description The most important part of a GSM network is so called Base Transceiver Station (BTS). Th ...

  4. [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  5. CodeForces 515C. Drazil and Factorial

    C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  6. [CareerCup] 17.3 Factorial Trailing Zeros 求阶乘末尾零的个数

    LeetCode上的原题,讲解请参见我之前的博客Factorial Trailing Zeroes. 解法一: int trailing_zeros(int n) { ; while (n) { re ...

  7. [codeforces 516]A. Drazil and Factorial

    [codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define  ...

  8. LeetCode Factorial Trailing Zeroes

    原题链接在这里:https://leetcode.com/problems/factorial-trailing-zeroes/ 求factorial后结尾有多少个0,就是求有多少个2和5的配对. 但 ...

  9. 【LeetCode】172. Factorial Trailing Zeroes

    Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: Your ...

随机推荐

  1. PL/SQL — 集合及常用方法

    PL/SQL中提供了常用的三种集合联合数组.嵌套表.变长数组,而对于这几个集合类型中元素的操作,PL/SQL提供了相应的函数或过程来操纵数组中的元素或下标.这些函数或过程称为集合方法.一个集合方法就是 ...

  2. Codeforces Round #209 (Div. 2)

    A: 要么是两次要么4次,判断是否在边界: #include<cstdio> using namespace std; int main() { int n,m,x; ; scanf(&q ...

  3. javaScript Code 用javascript确定每月第二个星期五

    废话少说只就上Code:     说明:getDay()方法获取星期(这里的星期是从0到6).参见:http://www.w3school.com.cn/js/js_obj_date.asp 中的ge ...

  4. linux 访问windows共享

    1. windows端建立一个用户user用于共享访问 2. 共享一个目录,设置user可以访问,并在windows系统中确认可以访问 3. linux端创建一个用于挂载共享目录的目录    mkdi ...

  5. SQL模糊查询与删除多条语句复习

    string IDlist="1,2,3"; 批量删除数据 StringBuilder strsql=new StringBuilder(); strSql.Append(&quo ...

  6. javaweb学习总结(四十)——编写自己的JDBC框架

    一.元数据介绍 元数据指的是"数据库"."表"."列"的定义信息. 1.1.DataBaseMetaData元数据 Connection.g ...

  7. A9两款芯片管脚数目

        Exynos 4412   bga786; S5P4418  bga513 

  8. iconv装换文件编码格式

    最近在mac上编译xml文本文件的时候用vim打开文件汉字总是显示乱码,修改.vimrc,修改iterm编码格式各种方法都使用遍了.最后通过iconv工具将原来的文件编码格式直接转为UTF-8解决掉. ...

  9. bzoj1084

    乍一看这题好难,根本不会: 直到看到1<=m<=2…… 显然分类讨论dp, 很快想到这题的dp和poj2430相类似 m=2的时候f[i,j,k]表示到第i行用了j个矩阵结尾状态为k时最大 ...

  10. Linux Kernel ‘mp_get_count()’函数本地信息泄露漏洞

    漏洞名称: Linux Kernel ‘mp_get_count()’函数本地信息泄露漏洞 CNNVD编号: CNNVD-201311-054 发布时间: 2013-11-06 更新时间: 2013- ...