题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1101 直接莫比乌斯反演. 代码如下: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; ; int pri[xn],cnt,mu[xn]; bool vis[xn]; int rd() { ,f=; char ch=ge…
gcd(x,y)=d-->gcd(x/d,y/d)=1. 即求Σ(i<=n/d)Σ(j<=m/d) e(gcd(i,j)) 因为e=miu×1,可以卷积. 因为多组询问,需要sqrt(n)计算. #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define int long long using namespace std; int n,m…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1101 #include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace std; ; int T,n,m,D,u[N],pri[N];bool vis[N]; int rdn() { ;;char ch=getchar(); ;ch=getchar…
题目: http://www.lydsy.com/JudgeOnline/problem.php?id=1101 题解: http://www.cnblogs.com/mrha/p/8203612.html 数学公式太难打了,核心思想是化成gcd(i,j)==1,然后用莫比乌斯反演变成枚举约数d,然后再搞式子 #include<cstdio> #include<algorithm> #define N 50005 typedef long long ll; using namesp…