——————数学——————
文章平均质量分 66
DT2131
Rage, rage against the dying of the light.Do not go gentle into that good night.
展开
-
POJ 2215 扩展欧几里得
POJ 2115E - ETime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluSubmit StatusDescriptionA Compiler Mystery: We are given a C-language style for原创 2016-08-03 14:11:29 · 393 阅读 · 0 评论 -
CodeForces - 757B Bash's Big Day (分解素因子)
题意: 给出N个数,从中挑选几个数,要求每个数的 gcd 不等于 1 ,问满足条件的数集最大有几个数?思路: 将每个数进行素数分解,统计素数出现的次数,素数中出现最多次的,就是所求最大数集的gcd,答案就是它出现次数。 注意到数字1的特殊性,所以在统计时略去。代码:#include using namespace std;co原创 2017-01-14 09:31:49 · 795 阅读 · 0 评论 -
中国剩余定理 模板
int Extended_Euclid(int a,int b,int &x,int &y) //扩展欧几里得算法 { int d; if(b==0) { x=1;y=0; return a; } d=Extended_Euclid(b,a%b,y,x); y-=a/b*x;原创 2016-07-26 10:49:53 · 598 阅读 · 0 评论 -
CodeForces 688D Remainders Game(中国剩余定理)
题意:给出c1,c2,...cn,问对于任何一个正整数x,给出x%c1,x%c2,...的值x%k的值是否确定;思路:中国剩余定理。详见大神博客:ACdreamer#include #include #include #include #include #include using namespace std;long long gcd(long long a,long原创 2016-09-21 21:37:33 · 660 阅读 · 0 评论 -
素数筛模板
int prime[(int)1e6+5];void getP(int MAXN){ memset(prime,0,sizeof(prime)); for(int i=2; i<=MAXN; i++) { if(!prime[i])prime[++prime[0]]=i; for(int j=1; j<=prime[0]&&prime[j原创 2016-07-26 10:15:44 · 438 阅读 · 0 评论 -
HDU 2669 扩展欧几里得
HDU 2669B - BTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescriptionThe Sky is Sprite. The Birds is Fly in the Sky. The Wind is原创 2016-08-03 13:33:28 · 485 阅读 · 0 评论 -
欧拉函数算法分析
在数论中,对正整数N,欧拉函数是小于或等于N的数中与N互质的数的数目。N的欧拉函数值记为 phi(n)例如 phi(8)=4 (4个与8互质的数分别为 1 3 5 7)通式: ,其中p1, p2……pn为x的所有质因数,x是不为0的整数。φ(1)=1(唯一和1互质的数(小于等于1)就是1本身)。 (注意:每种质因数只一个。比如12=2*2*3那么φ(12)=原创 2016-08-04 11:39:58 · 2599 阅读 · 0 评论 -
欧拉函数模板
phi(x):int p[MAXN];void phi(){ for(int i=1;i<MAXN;i++) p[i]=i; for(int i=2;i<MAXN;i++){ if(p[i]==i){ for(int j=i;j<MAXN;j+=i) p[j]-=p[j]/i; }原创 2016-08-04 11:42:36 · 430 阅读 · 0 评论 -
欧几里得和扩展欧几里得算法分析
参考自:百度百科见以下代码:int gcd(int x,int y){ if(y) return gcd(y,x%y); return x;}欧几里得算法很容易理解,同辗转相除法。那么重点是扩展欧几里得(EX_GCD):简单而言扩展欧几里得算法就是一种求二元一次方程(Ax+By=C)的一种方法:在此我们先讨论最原始的情况:Ax+By=gcd(A,B);原理原创 2016-08-09 12:35:48 · 370 阅读 · 0 评论 -
程序观点下的线性代数
来源:Todd Wei 的博客(@文艺复兴记)链接:http://www.cnblogs.com/weidagang2046/p/linear-algebra-from-programming-perspective.html程序观点下的线性代数线性代数是什么?在大学数学学科中,线性代数是最为抽象的一门课,从初等数学到线性代数的思维跨度比微积分和概率统计转载 2016-12-22 12:30:12 · 777 阅读 · 0 评论 -
POJ 1061 裸的扩展欧几里得
POJ 1061C - CTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %lluSubmit StatusDescription两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自原创 2016-08-03 13:23:27 · 531 阅读 · 0 评论 -
HDU 1576 扩展欧几里得&&暴力
HDU 1576A - ATime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescription要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,原创 2016-08-03 13:30:07 · 350 阅读 · 0 评论 -
Gym - 101341I Matrix God
题意: 给出 n * n 的 A , B ,C 三个矩阵,问 A * B 是否等于 C 思路: n 太大,不能暴力。O(n^3) 我们可以将矩阵变化压缩一下。转化为O(n^2)。代码:#include #include #include #include #include using namespace std原创 2017-05-08 18:09:59 · 512 阅读 · 0 评论