多学习。

摘要: AcWing872.最大公约数 题解 #include <iostream> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n, x, y; cin >> n 阅读全文
posted @ 2022-06-02 20:34 czyaaa 阅读(31) 评论(0) 推荐(0)
摘要: AcWing871.约数之和 题解 约数定理 #include <iostream> #include <cmath> #include <unordered_map> using namespace std; const int MOD = 1e9 + 7; typedef long long L 阅读全文
posted @ 2022-06-02 20:26 czyaaa 阅读(46) 评论(0) 推荐(0)
摘要: AcWing870.约数个数 题解 约数定理 #include <iostream> #include <unordered_map> using namespace std; typedef long long LL; const int MOD = 1e9 + 7; int main() { i 阅读全文
posted @ 2022-06-02 20:16 czyaaa 阅读(66) 评论(0) 推荐(0)
摘要: 约数个数 约数之和 阅读全文
posted @ 2022-06-02 19:57 czyaaa 阅读(182) 评论(0) 推荐(0)
摘要: AcWing869.试除法求约数 题解 #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> get_divisors(int n) { vector<int> res; 阅读全文
posted @ 2022-06-02 19:53 czyaaa 阅读(37) 评论(0) 推荐(0)
摘要: AcWing868.筛质数 题解 任何数都可以分解成:若干个质数。 也就是说每个数都可以由它的 最小质因子×另一个数得出 比如说:i=6的最小质因子是2, st[26] = true 为什么不把36也筛掉 因为36=18可 通过 st[29]筛选掉 也就是说只要你这个数在范围内,我在后面必定可以用最 阅读全文
posted @ 2022-06-02 11:15 czyaaa 阅读(42) 评论(0) 推荐(0)
摘要: AcWing867.分解质因数 题解 首先我们要明白算术基本定理,任何数都是由质数组成的,比如说 4是由22, 9由33等等 故该算法通过将前面的质因数除尽就不会被非质数干扰,比如说一个数能被4整除,必然能分解成2个2. 同时,我们要将该算法优化为O(sqrt(n))必须明白,n中最多包含一个大于s 阅读全文
posted @ 2022-06-02 10:58 czyaaa 阅读(97) 评论(0) 推荐(0)
摘要: AcWing866.试除法判定质数 题解 注意is_prime函数中的循坏要i/n,因为i * i ⇐ n中i*i可能会爆精度。 #include <iostream> #include <cstdio> using namespace std; bool is_prime(int n) { if( 阅读全文
posted @ 2022-06-02 10:38 czyaaa 阅读(54) 评论(0) 推荐(0)