素数问题_算数基本定理
2015-10-29 15:14
260 查看
定理:每个大于1 的正整数n都可以被唯一地写成素数的乘积,在乘积中的素因子按照非降序排列。正整数n的分解式n = p1^a1 * p2^a2****pk^ak 称为n的标准分解式,其中p1, p2, ...pk是素数,p1<p2<....pk, 且a1,a2....ak是正整数。性质1:若n的标准素因子分解表达式为上面所述,设d(n)为n的素因子的个数,则 d(n) = (a1+1) * (a2+1) * *** (ak + 1). 性质2:n!的素因子分解中的素数p的幂为[n/p] + [n/p^2] + [n/p^3] + ........例题:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;typedef long long int LL ;int main() {int m;cin >> m;while (m --) {LL n;cin >> n;int num = 5;int res = 0;while (n /num) {res += n/num;num *= 5;}cout << res << endl;}return 0;}
n!后面有多少个0 | |||
| |||
description | |||
从输入中读取一个数n,求出n!中末尾0的个数。 | |||
input | |||
输入有若干行。第一行上有一个整数m,指明接下来的数字的个数。然后是m行,每一行包含一个确定的正整数n,1<=n<=1000000000。 | |||
output | |||
对输入行中的每一个数据n,输出一行,其内容是n!中末尾0的个数。 | |||
sample_input | |||
3 3 100 1024 | |||
sample_output | |||
0 24 253 | |||
hint | |||
source |
相关文章推荐
- maven缺少依赖包,强制更新命令
- [Windows Server 2012] IIS自带FTP配置方法
- ci整合Smarty-3.1.18
- iOS 如何解决UITableView刷新卡顿现象
- 关于mysql的用户管理,笔记
- 素数问题_算数基本定理
- Android判断网络连接状态代码
- 解决linux 出现如下报错:Another app is currently holding the yum lock;
- 从头开始实现神经网络:入门
- 使用Linux正则表达式灵活搜索文件中的文本
- 「Maven Tips」(一)自动更新jar包
- dbus pc机上开发环境的建立
- Android开发学习:使用已有的sql数据库
- 实现二叉搜素树迭代器--进军硅谷
- opentld 出错解决方案
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- cpufreq 五种模式
- @RequestMapping 用法详解之地址映射
- EventUtil 跨浏览器事件处理对象
- AWS免费服务器申请