摘要:
int gcd(int a, int b){ return b ? gcd(b, a % b) : a;} 阅读全文
posted @ 2022-12-08 21:15
山海自有归期
阅读(19)
评论(0)
推荐(0)
摘要:
int phi(int x){ int res = x; for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) { res = res / i * (i - 1); while (x % i == 0) x /= i; } if (x > 1) res 阅读全文
posted @ 2022-12-08 21:15
山海自有归期
阅读(59)
评论(0)
推荐(0)
摘要:
int primes[N], cnt; // primes[]存储所有素数int euler[N]; // 存储每个数的欧拉函数bool st[N]; // st[x]存储x是否被筛掉 void get_eulers(int n){ euler[1] = 1; for (int i = 2; i < 阅读全文
posted @ 2022-12-08 21:15
山海自有归期
阅读(67)
评论(0)
推荐(0)
摘要:
vector<int> get_divisors(int x){ vector<int> res; for (int i = 1; i <= x / i; i ++ ) if (x % i == 0) { res.push_back(i); if (i != x / i) res.push_back 阅读全文
posted @ 2022-12-08 21:15
山海自有归期
阅读(18)
评论(0)
推荐(0)
摘要:
求 m^k mod p,时间复杂度 O(logk)。 int qmi(int m, int k, int p){ int res = 1 % p, t = m; while (k) { if (k&1) res = res * t % p; t = t * t % p; k >>= 1; } ret 阅读全文
posted @ 2022-12-08 21:14
山海自有归期
阅读(26)
评论(0)
推荐(0)

浙公网安备 33010602011771号