NEFU 118
其实一道公式题:
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的更多相关文章
- NEFU 118 - n!后面有多少个0 & NEFU 119 - 组合素数 - [n!的素因子分解]
首先给出一个性质: n!的素因子分解中的素数p的幂为:[ n / p ] + [ n / p² ] + [ n / p³ ] + …… 举例证明: 例如我们有10!,我们要求它的素因子分解中2的幂: ...
- NEFU 118 n!后面有多少个0【数论】
http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=118 求n!后面有多少个0(1<=n<=1000000000) ...
- 数论 - 算数基本定理的运用 --- nefu 118 : n!后面有多少个0
题目链接:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php Mean: 略. analyse: 刚开始想了半天都没想出来,数据这么大,难道是有什么 ...
- 算数基本定理 - nefu 118
算数基本定理 每个大于1的正整数都可以被唯一分解为素数的成绩,在乘积中的素因子按照非降序排列 a = p1^a1 * p2^a2 * ... pn^an; b = p1^b1 * p2^b2 * .. ...
- nefu 118 n!后面有多少个0 算数基本定理,素数分解
n!后面有多少个0 Time Limit 1000ms Memory Limit 65536K description 从输入中读取一个数n,求出n! 中末尾0的个数. input 输入有若干行.第一 ...
- 118. Pascal's Triangle
题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...
- 118. 119. Pascal's Triangle -- 杨辉三角形
118. Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...
- leetcode 118
118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, ...
- 【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, ...
随机推荐
- webpack到底怎么用?
webpack到底怎么用? https://www.zhihu.com/question/39290543
- express 4.2.0 使用session和cookies
express 4.2.0 使用session和cookies https://my.oschina.net/u/1466553/blog/294336
- 21. Merge Two Sorted Lists[E]合并两个有序链表
题目 Merge two sorted linked lists and return it as a new list. The new list should be made by splicin ...
- BZOJ 4259 FFT
思路: 为什么好多字符串的题都可以用FFT啊.... 我们其实是要判断$\Sigma (a[i]-b[i])^2*a[i]*b[i]==0$ 那就把a串翻转过来 把 上式展开 大力做几遍FFT就好啦~ ...
- 派遣函数IRP
派遣函数是Windows驱动程序中的重要概念.驱动程序的主要功能是负责处理I/O请求,其中大部分I/O请求是在派遣函数中处理的. 用户模式下所有对驱动程序的I/O请求,全部由操作系统转换为一个叫做IR ...
- 等等空格用法
平时经常用到 空格转移字符,记住一个 表示一个字符就可以了. Non-Breaking SPace 记住它是什么的缩写,更有助于我们记忆和使用.下面的字符转义自己视图翻译一下. 记录一下,空格的转 ...
- express搭建一个web服务器
npm install express -g express这个库可以使用了. npm install express-generator -g ...
- Spring DATA MongoDB @DBref查询,or和and联合查询
@DBref文档关联,在按该类型查询的时候,在字段名后加上关联表的字段名即可,如: Criteria.where("bloggroup.$id"), $id代表关联表的oid字段. ...
- HDFS开发中的一些问题(逐步补充)
1.windows操作系统下运行时报:Failed to locate the winutils binary in the hadoop binary path java.io.IOExcept ...
- windows form 相关
设置FormBorderStyle属性为none 让它成为一个无边框窗体