题意 题目链接 Sol 开始用反演推发现不会求\(\mu(k)\)慌的一批 退了两步发现只要求个欧拉函数就行了 \(ans = \sum_{d | n} d \phi(\frac{n}{d})\) 理论上来说复杂度是\(O(n)\)的,但是\(d\)的值十分有限.在\(2^{32}\)内最多的约数也只有1920个. /* */ #include<bits/stdc++.h> #define LL long long #define int long long const int MAXN =…
求 \(\sum\limits_{i=1}^{n}gcd(i,n)\) Solution 化简为 \(\sum\limits_{i|n}^{n}φ(\dfrac{n}{i})i\) 筛出欧拉函数暴力求答案即可 #include <bits/stdc++.h> using namespace std; #define int long long int phi(int n) { int m = floor(sqrt(n + 0.5)), ans = n; for (int i = 2; i &l…
传送门 Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7327 Accepted: 2416 Description Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms.…
Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6383 Accepted: 2043 Description Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now…
Code: #include<cstdio> #include<algorithm> #include<cmath> #include<string> using namespace std; typedef long long ll; void setIO(string a){freopen((a+".in").c_str(),"r",stdin);} int main(){ //setIO("input&…
Longge's problem Description Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a problem comes: Given an integer N(1 < N < 2^31),you are to calculate ∑gcd(i,…