随笔分类 - 算法大全 / 数论
摘要:int lowbit(int x){return x&(-x);} bool check(int x){ if(lowbit(x)!=x)return true; else return false; }
阅读全文
摘要:for(int j=2;j<=sqrt(x);j++){ while(!(x%j)){ mp[j]++; x/=j; } } if(x!=1){ mp[x]++; }
阅读全文
摘要:#include<bits/stdc++.h> #define int long long using namespace std; int n,p; int gcd(int a,int b,int &x,int &y){ if(b==0){ x=1; y=0; return a; } int d=
阅读全文
摘要:模板 #include<bits/stdc++.h> using namespace std; const int N=1e8+10; int p[N]; bitset<N>vis; int n; void ola(){ int cnt=0; for(int i=2;i<=N;i++){ if(!v
阅读全文
摘要:思路:先用素数筛把20000以内的素数筛出来,然后枚举两个素数 //哥德巴赫猜想(升级) #include<bits/stdc++.h> using namespace std; const int N=20005; bitset<N>vis; vector<int>p; void prime(){
阅读全文
摘要:哥德巴赫猜想:任意一个大于2的偶数都可以写成两个质数之和 思路:枚举质数 //哥德巴赫猜想 #include<bits/stdc++.h> using namespace std; bool check(int x){ if(x<=1)return false; for(int i=2;i<=sqr
阅读全文