破结论没听说过,上式推导到第三步的时候有了O(nlogn) 的做法(枚举倍数+1最后前缀和),并且这种做法可以直接应用到向上取整的计算中,详见forever97 但由于d(n)是积性函数,故可O(n)求 代码参考这里 #include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e6+5; const LL MOD = 1e9+7; LL f[N], g[N]; void init() { f…
题目链接 比赛时没抓住重点,对那个受限制的“分数求和”太过关心了..其实如果先利用莫比乌斯函数的一个性质把后面那个[gcd(i,j)=1]去掉,那么问题就可以简化很多.公式如下 这和之前做过的一道题很相似..(见http://www.cnblogs.com/Just--Do--It/p/7326572.html) 这个式子显然是可以用分块+预处理mu[i]前缀和的方法来做. 预处理复杂度是O(n),分块解决单组询问复杂度是O(sqrt(n)) 求g[n]可以用递推式来解决. 对比g[n]和g[n…
Battlestation Operational Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description > The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death S…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6134 题意: 解法: 那么g(n)怎么求,我们尝试打表发现g(n)是有规律的,g(n)=g(n-1)+d(n-1)+1,其中d(i)表示i的因子个数,这个我们是可以通过线性筛O(n)处理出来的,之后再O(n)维护g(i)的前缀和,就可以在单组sqrt(n)的复杂度下得到答案了. #include <bits/stdc++.h> using namespace std; typedef long l…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6134 [题目大意] 求$\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{i}{j}}\rceil}[ (i,j)==1 ]$ [题解] 设 $g(i)=\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{i}{j}}\rceil}$,$h(i)=\sum_{i=1}^{n}{\sum_{j=1}^{i}\lceil{\frac{…
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-si…
Problem Description   > The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-siz…
/* HDU 6170 - Two strings [ DP ] | 2017 ZJUT Multi-University Training 9 题意: 定义*可以匹配任意长度,.可以匹配任意字符,问两串是否匹配 分析: dp[i][j] 代表B[i] 到 A[j]全部匹配 然后根据三种匹配类型分类讨论,可以从i推到i+1 复杂度O(n^2) */ #include <bits/stdc++.h> using namespace std; const int N = 2505; int t;…
Distinct Values Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2298    Accepted Submission(s): 740 Problem Description Chiaki has an array of n positive integers. You are told some facts about…
OO's Sequence                                                          Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                                                                             T…