
数论
文章平均质量分 68
数论
Drogal_dracarys
If you sleep now , you will hava a dream. But if you study now , you will achieve your dream.
展开
-
卢卡斯定理模板
Lucas用来求C(n,m)%p的值,适用于解决n,m较大,p(一定为素数)小于1e6的情况。#include <iostream>#include <cstdio>#include <cstring>#define ll long longusing namespace std;const int maxn = 1e6+5;const int mod = 1e9+7;using namespace std;ll quick_mod(ll a, ll b转载 2020-10-20 11:40:17 · 200 阅读 · 0 评论 -
欧几里得gcd与拓展欧几里得exgcd
欧几里得算法求gcd辗转相除法 求两个数的最大公约数int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}证明(来自百度百科)其计算原理依赖于下面的定理:定理:两个整数的最大公约数等于其中较小的那个数和两数相除余数的最大公约数。最大公约数(Greatest Common Divisor)缩写为GCD。gcd(a,b) = gcd(b,a mod b) (不妨设a>b 且r=a mod b ,r不为0)证法一a可以表示成a = kb + r原创 2020-10-14 23:39:12 · 335 阅读 · 1 评论 -
欧拉筛法(线性筛素数)
以下内容转自https://blog.youkuaiyun.com/Losk_0/article/details/87884390#include<cstdio>#include<cstring>using namespace std;int main(){ int n,cnt=0; int prime[10001]; //存素数 bool vis[10001];//保证不做素数的倍数 scanf("%d",&n); memset(vis,false,sizeof(vi转载 2020-10-14 23:21:54 · 274 阅读 · 0 评论