随笔分类 -  数论

数论模板和刷题
摘要:https://blog.csdn.net/MamiyaHasaki/article/details/120644325?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~defau 阅读全文
posted @ 2022-03-03 21:21 fengzlj 阅读(90) 评论(0) 推荐(0) 编辑
摘要:数论分块 n/i 有2*sqrt(n)种情况 2.对于n/i 有分块区间 [ l , r ] , 其中 r = n / ( n / l ) for(int l=1,r;l<=n;l=r+1){ LL a=n/l;//当前区间中的数 r=n/(n/l);//区间的右端点 //do something} 阅读全文
posted @ 2022-02-26 23:19 fengzlj 阅读(26) 评论(0) 推荐(0) 编辑
摘要://中国剩余定理 # include <bits/stdc++.h>using namespace std;​typedef long long LL;const int MAXN=50;LL a[MAXN];LL b[MAXN];int k;LL mul(LL a,LL b,LL mod){ LL 阅读全文
posted @ 2022-02-26 23:18 fengzlj 阅读(23) 评论(0) 推荐(0) 编辑
摘要://求逆元//扩展gcd//1.65s# include <bits/stdc++.h>using namespace std;int exgcd(int a,int b,int &x,int &y){ if (b==0) { x=1,y=0;return a; } int d=exgcd(b,a% 阅读全文
posted @ 2022-02-26 23:17 fengzlj 阅读(24) 评论(0) 推荐(0) 编辑
摘要:# include <bits/stdc++.h>using namespace std;typedef long long LL;LL quick_pow(LL a,LL b,LL mod){ LL ret=1; while(b) { if(b&1) ret=ret*a%mod; a=a*a%mo 阅读全文
posted @ 2022-02-26 23:17 fengzlj 阅读(36) 评论(0) 推荐(0) 编辑
摘要://数学备忘录 //数学 //素数 //判定素数​bool Is_prime(int n){ if(n==1) return false; if(n==2||n==3) return true; if(n%6!=1&&n%6!=5) return false; for(register int i= 阅读全文
posted @ 2022-02-26 23:16 fengzlj 阅读(27) 评论(0) 推荐(0) 编辑
摘要:矩阵乘法 //矩阵乘法,斐波那契数列# include <bits/stdc++.h>using namespace std;​typedef long long LL;const LL mod=1e9+7;inline void mul(LL f[2],LL a[2][2]){ LL c[2]; 阅读全文
posted @ 2022-02-26 23:15 fengzlj 阅读(50) 评论(0) 推荐(0) 编辑
摘要:杜教筛 此处为莫比乌斯函数和欧拉函数的 # include <bits/stdc++.h>using namespace std;​typedef long long LL;typedef unsigned long long ULL;const int MAXN=5e6;int v[MAXN+10 阅读全文
posted @ 2022-02-26 23:13 fengzlj 阅读(62) 评论(0) 推荐(0) 编辑
摘要://二次剩余 //一般是求 x^2=n(mod p) 的解的,其中一般是保证p为奇素数,但是这套板子还处理了2的情况,把素数的情况大部分都包含了# include <bits/stdc++.h>using namespace std;typedef long long LL;# define ran 阅读全文
posted @ 2022-02-26 23:13 fengzlj 阅读(38) 评论(0) 推荐(0) 编辑
摘要:# include <bits/stdc++.h>#define MAX_L 2005 //最大长度,可以修改using namespace std; class bign{public: int len, s[MAX_L];//数的长度,记录数组//构造函数 bign(); bign(const 阅读全文
posted @ 2022-02-26 23:13 fengzlj 阅读(28) 评论(0) 推荐(0) 编辑
摘要://Pollard_Rho && Miller_Rabin class类​//跑的快的时候可以到1.01s #pragma GCC optimize("Ofast")#include<bits/stdc++.h>typedef long long LL;typedef long double LD; 阅读全文
posted @ 2022-02-26 23:12 fengzlj 阅读(68) 评论(0) 推荐(0) 编辑
摘要:N次剩余 //【题意】 给定newx,k,m,方程(x^k)%m=newx,求在模m意义下的所有解x//【限制】 0 <= newx,m,k <= 1.5*10^15; m是素数# include <bits/stdc++.h>using namespace std;# define LL __in 阅读全文
posted @ 2022-02-26 23:11 fengzlj 阅读(167) 评论(0) 推荐(0) 编辑
摘要:BSGS //unordered_map<LL,LL>m;// 300ms# include <bits/stdc++.h>using namespace std;​typedef long long LL;unordered_map<LL,LL>m;LL quick_pow(LL a,LL b,L 阅读全文
posted @ 2022-02-26 23:10 fengzlj 阅读(17) 评论(0) 推荐(0) 编辑
摘要:Lucas //求c(n,m)%p 其中p是质数 # include <bits/stdc++.h>using namespace std;​typedef long long LL;LL mulit(LL a,LL b,LL mod){ LL res=0; while(b){ if(b&1) re 阅读全文
posted @ 2022-02-26 23:10 fengzlj 阅读(47) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h>using namespace std;inline __int128 read(){ __int128 x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=g 阅读全文
posted @ 2022-02-26 23:09 fengzlj 阅读(181) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示