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 ...
随机推荐
- 有用的dede表单代码
<form action="" class="demoform"> <table> ...
- [ssc] 数据库管理工具——SQuirreL SQL Client使用入门
简单介绍: SQuirrel SQL Client是一个用Java写的数据库客户端,用JDBC统一数据库访问接口以后,可以通过一个统一的用户界面来操作MySQL PostgreSQL MSSQL Or ...
- js(引用类型和setTimeout scope)
题目是群中小伙伴出的. var a = [1,2,3]; c= a //todo 限制条件 c 不能出现在 = 左边 console.log(a) console.log(c) console.log ...
- (07)odoo扩展API
* 打开XML-RPC 连接 >>> import xmlrpclib >>> srv, db = 'http://localhost:8069', ' ...
- Anagrams [LeetCode]
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...
- 148. Sort List -- 时间复杂度O(n log n)
Sort a linked list in O(n log n) time using constant space complexity. 归并排序 struct ListNode { int va ...
- cd命令进入D盘
CD命令是更改目录命令如果要进入D盘 不用这个命令 直接输入 D: 回车 即可要是你非要使用CD命令那要加参数/DCD D:系统只是认为你想在系统中记忆一下D盘所以还是返回原先目录例:D盘下有一个目录 ...
- asp.net 使用UrlRewritingNet.UrlRewriter组件URL重写,伪静态详解
目录 URL重写的业务需求 ReWritingNet组件主要功能 配置IIS(IIS7/8环境下) 程序代码 重写规则 一,URL重写的业务需求 顾客可以直接用浏览器bookmark功能将页面连结储存 ...
- input覆盖select实现select可写可选择
1.有时需要一个select选择框,但是对select选择框希望是既可以选择也可以进行输入.下边的代码就是在select选择框上放了一个input框,覆盖在select上面.实现伪装的select效果 ...
- SAP资产变动明细
*&---------------------------------------------------------------------* *& Report ZFIR027 * ...