数论-杜教筛
数论只会GCD
研二在读
展开
-
51nod 1237 杜教筛
题解参考1238code:#include <bits/stdc++.h> using namespace std; typedef long long ll;const int N = 1000001; const ll mod = 1e9 + 7; const ll inv = (mod + 1) / 2; const int mo = 2333333;bool isPrime[N]; ll p原创 2017-08-07 18:51:14 · 460 阅读 · 0 评论 -
51nod 1238 杜教筛
传送门:51nod 1238题意求G(N)=∑i−1N∑j=1Nlcm(i,j) G(N) = \sum_{i - 1}^N\sum_{j=1}^Nlcm(i, j) 题解首先G(N)=∑i=1N∑j=1Nlcm(i,j)=2∑i=1N∑j=1ilcm(i,j)−∑i=1Nlcm(i,i)=2∑i=1Ni∑d|i∑u=1idu[gcd(u,id)=1]−N(N+1)2=2∑i=1Ni∑d|iidϕ原创 2017-08-07 16:37:22 · 829 阅读 · 0 评论 -
HDU 5608 莫比乌斯反演 + 莫比乌斯函数前缀和
传送门: HDU 5608 题解: 令 G(n) = n ^ 2 - 3 * n + 2 先反演得:f(n)=∑d|nG(d)∗u(nd)f(n) = \sum_{d|n}G(d) * u(\frac{n}{d})令: A(n)=∑i=1nf(i)A(n) = \sum_{i = 1}^nf(i) 则:A(n)=∑i=1nf(i)=∑i=1n∑d|iG(d)∗u(id)A(n) = \sum_原创 2017-08-06 18:15:37 · 1269 阅读 · 3 评论