随笔分类 - 数学
摘要:``` #include #include #include #include #include #define ll long long using namespace std; const int N=200005; int primes[N]; bool st[N]; int cnt; void init(int n) { memset(st, 0, sizeof st); cnt = 0;
阅读全文
摘要:```#include#include#include#includeusing namespace std;typedef long long LL;const int maxn = 1e5 + 5;const int inf = 1e6 + 5;int a[maxn],d[maxn];int main(){ int T,n; scanf("%d",&T); for(int cas=1; cas...
阅读全文
摘要:``` //序列具有周期性 #include #include #include #include using namespace std; typedef long long ll; const int N=5e4+10; ll sum[N]; ll a,b,q; ll calc(ll x) { return x/(a*b)*sum[a*b]+1ll*sum[x%(a*b)]; } void s
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e6+10; int primes[N],cnt; int phi[N]; bool st[N]; ll get_eulers(int n)
阅读全文
摘要://用定义直接求 #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--) { int x; cin>>x; int res=x; for(int i=2; i<=x/i; i++) { i
阅读全文
摘要:#include <iostream> #include <algorithm> using namespace std; //辗转相除法 //a和b的最大公约数 = b和(a % b)的最大公约数 int gcd(int a, int b) { //如果b不是0 返回gcd(b, a % b)】
阅读全文
摘要:#include <iostream> #include <algorithm> #include <unordered_map> #include <vector> using namespace std; typedef long long LL; const int N = 110, mod
阅读全文
摘要:#include <iostream> #include <algorithm> #include <unordered_map> #include <vector> using namespace std; typedef long long LL; const int N = 110, mod
阅读全文
摘要:#include <iostream> #include <algorithm> using namespace std; void divide(int x) { for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) { //枚举的都是质因子,因为已
阅读全文
摘要:#include <iostream> #include <algorithm> using namespace std; const int N= 1000010; int primes[N], cnt; bool st[N]; void get_primes(int n) { //n只会被最小质
阅读全文
摘要:#include <iostream> #include <algorithm> using namespace std; bool is_prime(int x) { if (x < 2) return false; for (int i = 2; i <= x / i; i ++ ) if (x
阅读全文