数论
csu-yuuki
这个作者很懒,什么都没留下…
展开
-
Luogu p2568 GCD
题目链接 https://www.luogu.com.cn/problem/P2398 问题分析: 代码如下: #include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e7 + 10; int phi[maxn]; int primes[maxn]; ll sum[maxn]; bool isnp[maxn]; int cnt = 0; void init(int n) {原创 2021-08-04 20:38:55 · 65 阅读 · 0 评论 -
Luogu p2398 GCD SUM
题目链接 https://www.luogu.com.cn/problem/P2398 问题分析: 代码如下: #include <bits/stdc++.h> #define ll long long using namespace std; const int maxn = 1e5 + 10; int phi[maxn]; int primes[maxn]; ll sum[maxn]; int cnt = 0; ll n; void init() { phi[1] = 1;原创 2021-08-04 20:16:39 · 74 阅读 · 0 评论 -
裴蜀定理简单应用
裴蜀定理 定理内容: 设aaa,bbb是不全为000的整数,则存在整数xxx,yyy使得a⋅xa\cdot xa⋅x +++ b⋅yb\cdot yb⋅y = gcd(x,y)\gcd(x,y)gcd(x,y)。 定理简单应用: 例题: 洛谷p4549 https://www.luogu.com.cn/problem/P4549 思路分析: 给定一个序列,求一个SSS满足S=S =S= ∑i=1n\sum\limits_{i=1}^ni=1∑nAi×XiA_i\times X_iAi×Xi,而原创 2021-07-30 18:53:55 · 402 阅读 · 0 评论 -
乘法逆元及简单利用
乘法逆元 定义: 如果一个线性同余方程ax{ax}ax≡ 1{1}1(modmodmod bbb),则xxx称为aaa modmodmod bbb的逆元,记作a−1a^{-1}a−1。 求逆元的常见方法及其模板 扩展欧几里得法: void exgcd(int a, int b) { if (!b) { x = 1; y = 0; return; }原创 2021-07-19 09:20:02 · 97 阅读 · 0 评论 -
洛谷p1072[NOIP2009 提高组] Hankson 的趣味题
原题链接 题目分析如图: 代码如下: #include <bits/stdc++.h> using namespace std; int gcd(int x, int y) { while (y ^= x ^= y ^= x %= y); //正常求gcd(x,y)即可,不要这样写 return x; } int main() { int t; ios::sync_with_stdio(false); cin原创 2021-07-15 17:17:14 · 143 阅读 · 0 评论