nefu 118 质数在阶乘中的幂 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=118
来源:互联网 发布:万德数据库怎么用 编辑:程序博客网 时间:2024/05/16 05:01
#include<iostream>#include<cmath>using namespace std;int main(){ int k; cin>>k; int n; while(cin>>n) { int exponent=0; for(int i=1;pow(5.0,i)<=n;i++) exponent+=n/pow(5.0,i); cout<<exponent<<endl; }}
//应该发现 2的幂总比5高; 所以5的幂次等于零的个数
// 阶乘中求质数的幂的方法
利用这个结论还可以求质数在组合数中的幂 如 nefu 119 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=119
#include<iostream>#include<cmath>using namespace std;int main(){ int k; cin>>k; int n; double p; while(cin>>n>>p) { int exponent=0; for(int i=1;pow(p,i)<=n;i++) exponent+=n/pow(p,i); int exponent1=0; for(int i=1;pow(p,i)<=n*2;i++) exponent1+=2*n/pow(p,i); cout<<exponent1-exponent*2<<endl; }}
- nefu 118 质数在阶乘中的幂 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=118
- nefu 84 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=84
- nefu 117 素数分布 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=117
- http://acm.fafu.edu.cn/showproblem?problem_id=1005食物链 (第一次用类写,居然过了
- http://acm.hdu.edu.cn/showproblem.php?pid=1005
- http://acm.hdu.edu.cn/showproblem.php?pid=1333
- http://acm.hdu.edu.cn/showproblem.php?pid=2710
- http://acm.hdu.edu.cn/showproblem.php?pid=2866
- http://acm.hdu.edu.cn/showproblem.php?pid=1041
- http://acm.hdu.edu.cn/showproblem.php?pid=1719
- http://acm.hdu.edu.cn/showproblem.php?pid=2136
- http://acm.hdu.edu.cn/showproblem.php?pid=1166
- http://acm.hdu.edu.cn/showproblem.php?pid=3519
- http://acm.hdu.edu.cn/showproblem.php?pid=2446
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1874
- http://acm.hdu.edu.cn/showproblem.php?pid=1863
- http://acm.hdu.edu.cn/showproblem.php?pid=1879
- Android开发入门之监听ContentProvider中数据的变化
- Problem getting wireless networking to work in Windoes Server 2008R2
- Fibonacci Number Generator
- SVN强化
- 世界上最聪明的人都在做什么?
- nefu 118 质数在阶乘中的幂 http://acm.nefu.edu.cn/test/problemshow.php?problem_id=118
- ZOJ Problem Set - 1108 FatMouse's Speed
- MsSql 数据类型详解
- 获取html标签属性
- 设计模式(4) -- 单例模式(Singleton)
- str
- Rolap的数据存储模式
- 警惕中青年过劳死10大危险信号
- android 安全学习从何入手?