其实一道公式题:

n!中素数i的幂为:

[n/i]+[n/i^2]+[n/i^3]+[n/i^4]+......

#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; long long n; int main(){
long long two,five; int t;
scanf("%d",&t);
while(t--){
scanf("%lld",&n);
two=five=0;
for(long long i=2;i<=n;i*=2)
two+=(n/i);
for(long long i=5;i<=n;i*=5)
five+=(n/i);
printf("%lld\n",two>five?five:two);
}
return 0;
}

  

NEFU 118的更多相关文章

  1. NEFU 118 - n!后面有多少个0 & NEFU 119 - 组合素数 - [n!的素因子分解]

    首先给出一个性质: n!的素因子分解中的素数p的幂为:[ n / p ] + [ n / p² ] + [ n / p³ ] + …… 举例证明: 例如我们有10!,我们要求它的素因子分解中2的幂: ...

  2. NEFU 118 n!后面有多少个0【数论】

    http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=118 求n!后面有多少个0(1<=n<=1000000000) ...

  3. 数论 - 算数基本定理的运用 --- nefu 118 : n!后面有多少个0

     题目链接:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php Mean: 略. analyse: 刚开始想了半天都没想出来,数据这么大,难道是有什么 ...

  4. 算数基本定理 - nefu 118

    算数基本定理 每个大于1的正整数都可以被唯一分解为素数的成绩,在乘积中的素因子按照非降序排列 a = p1^a1 * p2^a2 * ... pn^an; b = p1^b1 * p2^b2 * .. ...

  5. nefu 118 n!后面有多少个0 算数基本定理,素数分解

    n!后面有多少个0 Time Limit 1000ms Memory Limit 65536K description 从输入中读取一个数n,求出n! 中末尾0的个数. input 输入有若干行.第一 ...

  6. 118. Pascal's Triangle

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...

  7. 118. 119. Pascal's Triangle -- 杨辉三角形

    118. Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...

  8. leetcode 118

    118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, ...

  9. 【LeetCode】118 & 119 - Pascal's Triangle & Pascal's Triangle II

    118 - Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, ...

随机推荐

  1. Linux shell脚本中shift的用法说明【转】

    本文转载自:http://blog.csdn.net/zhu_xun/article/details/24796235 Linux shell脚本中shift的用法说明 shift命令用于对参数的移动 ...

  2. UVa 11722(几何概率)

    题意:你和你的朋友要乘坐火车,并且都会在A城市相遇,你会在(t1,t2)中的任意时刻以相同的概率密度到达, 你朋友会在(s1,s2)中的任意时刻以相同的概率密度到达,你们的火车在A城市都会停留w分钟, ...

  3. 解决PopupWindow的阴影覆盖问题

    版权声明:本文为xing_star原创文章,转载请注明出处! 本文同步自http://javaexception.com/archives/108 PopupWindow阴影覆盖问题 最近这段时间需求 ...

  4. 数据库表结构导出sql语句

    在“对象资源管理器”中找到要导出的表,选中该表并单击右键,“编写表脚本为(S)”/“CREATE到(C)”/“新查询编辑器窗口”即可查看该表的建表语句,Ctrl+S保存为sql脚本文件

  5. (转载)tnsping不是内部或外部命令

    手动添加 D:\app\Administrator\product\11.2.0\client_1\bin 到系统环境变量 path里面

  6. windows form 相关

    设置FormBorderStyle属性为none 让它成为一个无边框窗体

  7. C++:数据流和缓冲区

    (1):C++之自定义的input缓冲区 原文链接:http://hi.baidu.com/nicker2010/item/d0c4cd2a7caf27c4ddf69aeb input stream用 ...

  8. 杭电2060WA

    #include<stdio.h> int main() { int n,num,p,q,i,a[]={2,3,4,5,6,7}; scanf("%d",&n) ...

  9. H5动效的常见制作手法

    众所周知,一个元素,动往往比静更吸引眼球: 一套操作界面,合适的动态交互反馈能给用户带来更好的操作体验: 一个H5运营宣传页,炫酷的动画特效定能助力传播和品牌打造. 近两年,小到loading动画,表 ...

  10. form 表单的另类触发方式:报错触发

    在用form表单提交的时候,遇到一个问题:表单未验证完,表单就提前提交了. 然后通过断点调试,发现form提交会因为函数报错提前提交. 即如果你的form提交过程中,没有执行到return true之 ...