poj1992 数论
//Accepted 168 KB 969 ms //n!中含有质因数p的个数为t=n/p+n/p^2+n/p^3+... #include <cstdio> #include <cstring> #include <iostream> using namespace std; ; int pri[imax_n]; void prime() { ;i<imax_n;i++) { for (int j=i*i;j<imax_n;j+=i) { pri[j]=; } } } int getNumber(int n,int k) { ; ) { ans+=n/k; n=n/k; } return ans; } void slove(int n,int k) { __int64 ans=; ;i<=n;i++) ) { ; ans*=t; } printf("%I64d\n",ans); } int main() { prime(); int n,k; while (scanf("%d%d",&n,&k)!=EOF) { slove(n,k); } ; }
//Accepted 900 KB 344 ms #include <cstdio> #include <cstring> #include <iostream> using namespace std; ; int pri[imax_n]; int a[imax_n][imax_n]; void prime() { ;i<imax_n;i++) { for (int j=i*i;j<imax_n;j+=i) { pri[j]=; } } } int getNumber(int n,int k) { ; ) { ans+=n/k; n=n/k; } return ans; } void getA() { ;i<=;i++) { ;j<=;j++) { ) a[i][j]=getNumber(i,j); } } } void slove(int n,int k) { __int64 ans=; ;i<=n;i++) ) { //printf("a[%d][%d]=%d\n",n,i,a[n][i]); //printf("a[%d][%d]=%d\n",k,i,a[k][i]); //printf("a[%d][%d]=%d\n",n-k,i,a[n-k][i]); ; ans*=t; } printf("%I64d\n",ans); } int main() { prime(); getA(); int n,k; while (scanf("%d%d",&n,&k)!=EOF) { slove(n,k); } ; }
poj1992 数论的更多相关文章
- Codeforces Round #382 Div. 2【数论】
C. Tennis Championship(递推,斐波那契) 题意:n个人比赛,淘汰制,要求进行比赛双方的胜场数之差小于等于1.问冠军最多能打多少场比赛.题解:因为n太大,感觉是个构造.写写小数据, ...
- NOIP2014 uoj20解方程 数论(同余)
又是数论题 Q&A Q:你TM做数论上瘾了吗 A:没办法我数论太差了,得多练(shui)啊 题意 题目描述 已知多项式方程: a0+a1x+a2x^2+..+anx^n=0 求这个方程在[1, ...
- 数论学习笔记之解线性方程 a*x + b*y = gcd(a,b)
~>>_<<~ 咳咳!!!今天写此笔记,以防他日老年痴呆后不会解方程了!!! Begin ! ~1~, 首先呢,就看到了一个 gcd(a,b),这是什么鬼玩意呢?什么鬼玩意并不 ...
- hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- 【BZOJ-4522】密钥破解 数论 + 模拟 ( Pollard_Rho分解 + Exgcd求逆元 + 快速幂 + 快速乘)
4522: [Cqoi2016]密钥破解 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 290 Solved: 148[Submit][Status ...
- bzoj2219: 数论之神
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- hdu5072 Coprime (2014鞍山区域赛C题)(数论)
http://acm.hdu.edu.cn/showproblem.php?pid=5072 题意:给出N个数,求有多少个三元组,满足三个数全部两两互质或全部两两不互质. 题解: http://dty ...
- ACM: POJ 1061 青蛙的约会 -数论专题-扩展欧几里德
POJ 1061 青蛙的约会 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %llu Descr ...
- 数论初步(费马小定理) - Happy 2004
Description Consider a positive integer X,and let S be the sum of all positive integer divisors of 2 ...
随机推荐
- association ,collection
mybatis 出现这个错误Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 2 ...
- 串行通讯之.NET SerialPort
第1章串行通讯之.NET SerialPort 2 1 枚举串口 2 2 打开/关闭串口 2 3 写数据 3 3.1 写二进制数据 3 3.2 写文本数据 4 4 ...
- EF Core » 影子属性
Caution:注意 This documentation is for EF Core. For EF6.x and earlier release see http://msdn.com/data ...
- 【转】 Live555
Ⅰ live555简介 Live555 是一个为流媒体提供解决方案的跨平台的C++开源项目,它实现了对标准流媒体传输协议如RTP/RTCP.RTSP.SIP等的支持.Live555实现了对多种音视频编 ...
- [saiku] 连接 mondrain 数据源出错-空指针错误
我的个亲娘,这个问题查半天终于查出来了. 一开始以为是配置的mysql的location连接有问题,各种修改啊各种尝试,还是不行. 好死不死报了空指针错误,让人无法下手. 后来发现是这样子的: 生成s ...
- XPath语法 在C#中使用XPath示例 【转http://www.cnblogs.com/yukaizhao/archive/2011/07/25/xpath.html】非常详细的文章
XPath语法 在C#中使用XPath示例 XPath可以快速定位到Xml中的节点或者属性.XPath语法很简单,但是强大够用,它也是使用xslt的基础知识. 示例Xml: <?xml ve ...
- hdu-----(1151)Air Raid(最小覆盖路径)
Air Raid Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- Permutations [LeetCode]
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...
- matlab(函数,变量)
- php unserialize 返回false的解决方法
php 提供serialize(序列化) 与unserialize(反序列化)方法. 使用serialize序列化后,再使用unserialize反序列化就可以获取原来的数据.(改表结构或者进行下面操 ...