题目大意

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. SDC(1)–Hold Time

    从以下两个论点触发可能会使Hold Time的计算理解起来更加容易: (1) H = SU – 1 ; (2) Hold Check的目的是确保Source Clock在某个边沿打出数据时,该数据不会 ...

  2. android报表图形引擎(AChartEngine)demo解析与源码

    AchartEngine支持多种图表样式,本文介绍两种:线状表和柱状表. AchartEngine有两种启动的方式:一种是通过ChartFactory.get***View()方式来直接获取到view ...

  3. entity framework extended library , bulk execute,deleting and updating ,opensource

    http://weblogs.asp.net/pwelter34/entity-framework-batch-update-and-future-queries

  4. CSS3 display:flex和display:box有什么区别?

    **区别**,仅是各阶段草案命名.- W3C 2009年第1次草案:[display:box;](https://www.w3.org/TR/2009/WD-css3-flexbox-20090723 ...

  5. Memcached(六)Memcached的并发实例

    package com.sinosuperman.memcached; import java.io.IOException; import java.net.InetSocketAddress; i ...

  6. 当页面编辑或运行提交时,出现“从客户端中检测到有潜在危险的request.form值”问题,该怎么办呢?

    最近在学习highcharts时,关于其中的导出功能,本来是想把导出的图片存放在本地,发现只有在电脑联网的情况下才可以一下导出图片,后来查阅了一番资料,才发现highcharts中的导出默认的官网服务 ...

  7. posix和system v有什么区别/?

    posix和system v有什么区别/?现在在应用时应用那一标准浮云484212 | 浏览 243 次 2014-11-06 10:362014-11-19 22:36 最佳答案们是有关信号量的两组 ...

  8. no identities are available for signing

    原地址:http://www.cnblogs.com/imzzk/p/3501868.html 今天将做好的app提交到app store,结果就出现标题上的错误.“No identities are ...

  9. Android 应用程序窗口化

    Android 应用程序窗口化与 Store 应用程序窗口化-Android,Windows,better,chrome,archon-远景-Win8|Win8.1|Windows8.1|Win10| ...

  10. 140. Word Break II

    题目: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where e ...