![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
Tearsゆ
破铜烂铁ACMer
展开
-
欧拉函数的一些性质及欧拉降幂
性质1.对于质数p, φ ( p ) = p − 1 φ§=p-1 φ§=p−1。2.若p为质数, n = p k n=p^k n=pk,则 φ ( n ) φ(n) φ(n)= p k p^k pk- p k − 1 p^{k-1} pk−1。3.欧拉函数是积性函数,但不是完全积性函数。若m,n互质,则 φ ( m ∗ n ) = φ ( m ) ∗ φ ( n ) φ(m*n)=φ(m)φ(n) φ(m∗n)=φ(m)∗φ(n)。特殊的,当m=2,n为奇数时,φ(2n)=φ(n)。4.当n&g原创 2022-05-27 11:15:56 · 187 阅读 · 0 评论 -
LCMs (莫比乌斯反演)
link记次数别用 map!!!!!我 wa烂了不知道哪里错了#include <bits/stdc++.h>using namespace std;#define int long long//typedef long long ll;typedef pair<int,int> pii;#define x first #define y second#define pb push_back#define inf 1e18#define IOS原创 2022-05-24 15:41:31 · 178 阅读 · 0 评论 -
acwing 215. 破译密码 (莫比乌斯反演+数论分块)
link思路我们需要了解一下莫比乌斯函数下来就是 我们如何在更优 的复杂度内求 a/i b/i我们可以想到 数论分块!!#include <bits/stdc++.h>using namespace std;#define int long long//typedef long long ll;typedef pair<int,int> pii;#define x first #define y second#define pb push_原创 2022-05-19 16:48:48 · 204 阅读 · 0 评论 -
Codeforces Round #613 (Div. 2) C. Fadi and LCM (二进制枚举
link题意给出lcm(a,b) 求max(a,b)每次只给出一个数 所以我们不需要预处理 直接根号n 暴力出他的因子然后 二进制枚举就行比较不错的一道简单数论吧#include <bits/stdc++.h>using namespace std;#define int long long//typedef long long ll;typedef pair<int,int> pii;#define x first #define y second#原创 2022-05-16 20:24:21 · 114 阅读 · 0 评论 -
质因数相关的几道好题
1#include <bits/stdc++.h>typedef long long ll;using namespace std;const int maxn = 4e7 + 10;bool vis[maxn];ll primes[maxn];ll sum[maxn];ll cnt;int main(){ for(ll i=2;i<maxn;i++) { if(!vis[i]) { primes[++cnt]=i; } for(ll j=原创 2022-05-04 12:53:21 · 85 阅读 · 1 评论 -
数学-数论分块
ans = 0;for(int l = 1, r; l <= n; l = r + 1){ r = n / (n / l); ans += n / l * (r - l + 1);} 分块后我们发现每一块 然后去计算就行 公差为k/left#include<bits/stdc++.h>using namespace std;int main(){ long long n, k, ans = 0; long long left = .原创 2022-04-30 16:08:08 · 200 阅读 · 0 评论