题目大意

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. sum_series() 求一列数的指定个数的数和(5个数字的和)

    #include <stdio.h> #include <stdarg.h> /*用sum_series() 求一列数的指定个数的数和(5个数字的和)*/ double sum ...

  2. merge into 和 update 的效率对比

    以前只考虑 merge into 只是在特定场合下方便才使用的,今天才发现,merge into 竟然会比 update 在更新数据时有这么大的改进.其实呢,merge into部分的update和u ...

  3. UILocalNotification本地通知

    // 执行通知一定要退出应用或挂起应用(进入后台)才能收到通知. 1.在iOS8及其以后版本中使用本地消息需要先获得用户的许可,否则无法成功注册本地消息.因此,我们将询问用户许可的代码片段添加到了ap ...

  4. 常用数据字典---bai

    --常用数据字典 -- system: normal; sysdba --查询所有的逻辑对象.所有. select count(1) from dba_objects; select * from d ...

  5. SVN服务器使用(一)

    源代码版本控制软件很多,像VSS,SVN还有其他的软件,各有优缺点.Subversion是优秀的版本控制工具,下面主要介绍这个软件的使用. Subversion下载地址: http://subvers ...

  6. 实时动态更新曲线图,x轴时间s随数据的变化而变化

    $(function () {    $(document).ready(function () {        Highcharts.setOptions({            global: ...

  7. HDU 1059 Dividing(多重背包)

    点我看题目 题意: 将大理石的重量分为六个等级,每个等级所在的数字代表这个等级的大理石的数量,如果是0说明这个重量的大理石没有.将其按重量分成两份,看能否分成. 思路 :一开始以为是简单的01背包,结 ...

  8. 服务器部署_linuix下 一台nginx 多域名

    近日朋友要我帮他调服务器, 一. 初步需求如下: 1. 一台服务器下要放三个应用,对应三个域名:www.aaa.com,www.bbb.com,www.ccc.com. 2. 其中后两个应用也要可以用 ...

  9. push 栈顶sp=sp-2 可以把立着的栈,向左侧倒下,那么形态就和反汇编时,内存的形态是一样的。小偏移的字节在前, 大的偏移字节在后

    push  栈顶sp=sp-2 可以把立着的栈,向左侧倒下,那么形态就和反汇编时,内存的形态是一样的.小偏移的字节在前, 大的偏移字节在后. 1 2 3 4 5 1 2 3 4 5

  10. MFC浅析(7) CWnd类虚函数的调用时机、缺省实现

    CWnd类虚函数的调用时机.缺省实现 FMD(http://www.fmdstudio.net) 1. Create 2. PreCreateWindow 3. PreSubclassWindow 4 ...