随笔分类 -  算法大全 / 数论

摘要:int lowbit(int x){return x&(-x);} bool check(int x){ if(lowbit(x)!=x)return true; else return false; } 阅读全文
posted @ 2024-01-18 20:28 yufan1102 阅读(12) 评论(0) 推荐(0)
摘要:for(int j=2;j<=sqrt(x);j++){ while(!(x%j)){ mp[j]++; x/=j; } } if(x!=1){ mp[x]++; } 阅读全文
posted @ 2024-01-09 21:05 yufan1102 阅读(13) 评论(0) 推荐(0)
摘要:#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= 阅读全文
posted @ 2023-12-19 14:34 yufan1102 阅读(8) 评论(0) 推荐(0)
摘要:模板 #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 阅读全文
posted @ 2023-12-18 21:55 yufan1102 阅读(21) 评论(0) 推荐(0)
摘要:思路:先用素数筛把20000以内的素数筛出来,然后枚举两个素数 //哥德巴赫猜想(升级) #include<bits/stdc++.h> using namespace std; const int N=20005; bitset<N>vis; vector<int>p; void prime(){ 阅读全文
posted @ 2023-12-16 13:44 yufan1102 阅读(43) 评论(0) 推荐(0)
摘要:哥德巴赫猜想:任意一个大于2的偶数都可以写成两个质数之和 思路:枚举质数 //哥德巴赫猜想 #include<bits/stdc++.h> using namespace std; bool check(int x){ if(x<=1)return false; for(int i=2;i<=sqr 阅读全文
posted @ 2023-12-16 13:23 yufan1102 阅读(17) 评论(0) 推荐(0)