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 ...
随机推荐
- rand()和srand()GetTickCount函数用法
标准库<cstdlib>(被包含于<iostream>中)提供两个帮助生成伪随机数的函数: 函数一:int rand(void):从srand (seed)中指定的seed开始 ...
- sqlserver计算表使用大小sql
) create table #spt_space ( ) null, [rows] int null, ) null, ) null, ) null, ) null ) set nocount on ...
- 学习HTML5之塔克大战(详细记录)
学了一些HTML5的一些基本知识,开始学习制作...... 介绍一些基本知识: px(像素)--->1px等于多少? 1cm or 2cm -->no no no! (1).像素是一个 ...
- 使用TypeScript开发程序
简介 TypeScript一直发展不错,我们公司在开发新功能时,考虑到程序的可维护性,使用了TypeScript编写浏览器上的程序,我们是从零开始使用TypeScript,甚至我连javascript ...
- MATLAB实现矩阵分块相乘
要实现一下功能,这里$\bf{x}_i$为行向量 $${\bf{A}} = \left[ \begin{array}{l}{{\bf{x}}_1}\\{{\bf{x}}_2}\end{array} \ ...
- 并查集 POJ 1988
#include <cstdio> #define N 30010 int pa[N]; //parent int siz_tree[N]; //size of tree int d[N] ...
- Octopus系列之开发中灵光点收集,先放到这里,后面会整理的
项目中引用的组件 1.System.Data.SQLite.dll 自行编译 SQLite-1.0.66.0-source 3.5的框架:F:\Code\开源项目\SQLite\1.0.66.0_x8 ...
- java 面向对象编程-- 第十三章 反射、类加载与垃圾回收
1.狭义JavaBean规范 Javabean必须包含一个无参数的public构造方法,方便通过反射的方式产生对象. 属性必须都是私有的. Javabean必须包含符合命名规范的get和set方法,以 ...
- GL10控制图形旋转
GL10提供了glRotatef(float angle , float x , float y , float z)方法,该方法用于控制旋转,该方法种angle控制旋转角度:而x.y.z参 ...
- Mongodb Management Studio
1.服务器管理功能添加服务器,删除服务器 2.服务器,数据库,表,列,索引,树形显示和状态信息查看 3.查询分析器功能.支持select,insert,Delete,update支持自定义分页函数 $ ...