poj2649 数论
//Accepted 420K 16MS
//考虑 0和n! does not divide
// 1和0! divides
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
<<)+;
int pri[imax_n];
int cnt;
void prime()
{
;i<imax_n;i++)
{
if ((long long )i*i<(long long )imax_n)
for (int j=i*i;j<imax_n;j+=i)
{
pri[j]=;
}
}
cnt=;
;i<imax_n;i++)
)
pri[cnt++]=i;
}
int getNumber(int n,int k)
{
;
) ;
)
{
ans+=n/k;
n/=k;
}
return ans;
}
int split(int n,int m)
{
int t;
//printf("n=%d\n",n);
) ;
)
{
) ;
;
}
;i<cnt && (__int64 )pri[i]*pri[i]<=(__int64 )n;i++)
{
)
{
//printf("pri=%d\n",pri[i]);
t=;
)
{
t++;
n/=pri[i];
}
int temp=getNumber(m,pri[i]);
//printf("temp=%d t=%d\n",temp,t);
;
}
}
)
{
int temp=getNumber(m,n);
) ;
}
;
}
int main()
{
prime();
int n,m;
while (scanf("%d%d",&n,&m)!=EOF)
{
int ans=split(m,n);
)
{
printf("%d divides %d!\n",m,n);
}
else
{
printf("%d does not divide %d!\n",m,n);
}
}
;
}
poj2649 数论的更多相关文章
- 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 ...
随机推荐
- C/C++中float和double的存储结构
int main (int argc, char **argv) { float a = 1.0f; cout <<"(int&)a = "<<(i ...
- 串行通讯之.NET SerialPort异步写数据
目录 第1章说明 2 1 为什么需要异步写数据? 2 2 异步写数据的代码 2 3 源代码 4 第1章说明 1 为什么需要异步写数据? 如下图所示,以波特率300打开一个串口. ...
- validate插件:验证密码没有空格 用户名是5-10位 至少包含数字和大小写字母中的两种字符
//校验密码是否含有空格 jQuery.validator.addMethod("notblank", function(value, element) { var pwdblan ...
- spring3-hibernate3整合
Spring与Hibernate整合关键点: 1) Hibernate的SessionFactory对象交给Spring创建: 2) hibernate事务交给spring的声明式事务管理. SH整合 ...
- 谈谈JPA-02-HelloWorld
使用JPA持久化对象的步骤 创建 persistence.xml, 在这个文件中配置持久化单元 需要指定跟哪个数据库进行交互; 需要指定 JPA 使用哪个持久化的框架以及配置该框架的基本属性 创建实体 ...
- wiki-editor语法
1.==标题== 2.::换行缩进 3.[[文件:example.png]] 图片 4.** 名字|名字 链接
- bug:C#线程间操作无效: 从不是创建控件" XX" 的线程访问它
今天遇到这个问题,百度了下,把解决的方法总结出来.我们在ui线程创建的子线程操作ui控件时,系统提示错误详细信息为:线程间操作无效: 从不是创建控件“XXX”的线程访问它. 就我知道的有三种方法,先看 ...
- JavaScript访问修改css样式表
1.访问元素中style属性的css样式 可以根据属性的ID或name标签利用dom操作直接访问到内部的css样式,直接使用style对象访问 <div id="myid" ...
- word文档中查找和替换空格符和回车符
空格符:^l 回车符:^p
- SAP采购订单审批记录增强
采购订单审核函数: BAPI_PO_RELEASE 结尾加上 ENHANCEMENT ZME28_PO. "active version DATA:LS_EKKO TYPE EKKO. DA ...