
数论——基本公式和代码模板
eeetttzhangji
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
欧几里得算法(gcd)和扩展欧几里得
int gcd(int a,int b) 求解a和b的最大公约数int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}这也是俗称的欧几里得算法。如果a和b的最大公约数是gcd,那么一定存在x和y使得a*x + b*y = gcd,int e_gcd(int a,int b,int &x,int &y){原创 2017-03-22 13:41:37 · 409 阅读 · 0 评论 -
有关素数的基础算法
素性测试bool is_prime(int n){ for(int i=2;i*i<=n;i++) { if(n%i==0) return false; } return n!=1; //1不是素数 }约数枚举vector divisor(int n){ vector res; for(int i=1;i*i<=n;i++) { if(n%i==0) {原创 2017-03-22 14:22:03 · 360 阅读 · 0 评论 -
快速幂
typedef long longll mod_pow(ll x,ll n,ll mod){ ll res=1; while(n>0) { if(n&1) res=res*x%mod; x=x*x%mod; n>>=1; } return res;}x的n次幂取余mod原创 2017-03-22 14:26:23 · 242 阅读 · 0 评论 -
素数筛选 素数分解
Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a prime number. However, Asya thinks an integer is interesting if the amount of it原创 2017-03-23 17:39:25 · 344 阅读 · 0 评论 -
数学题,不等式推导
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on转载 2017-05-23 15:25:45 · 416 阅读 · 0 评论 -
卡特兰数
先给出计算组合数的公式:#includeusing namespace std;int count_=0;//求组合数C(m,k)个数,k>=1int comb1(int m,int k)//(C(m,k)){ int i; for (i=m;i>=k;i--) { if (k>1) {原创 2017-05-19 21:13:09 · 301 阅读 · 0 评论